Seamlessly Deploying Dart Backend APIs with Globe

Mariam HamzatMariam Hamzat
8 min read

If you're a Dart developer exploring backend development, you're probably excited about what you can do. Dart is fast and flexible, which makes it great for Flutter and also a strong choice for building reliable server applications. But, like many others, you might have encountered a problem with “deployment”. Moving your Dart backend API from your computer to a live, scalable environment can often feel like navigating a puzzle.

You've built a great app; everything works perfectly on your computer. Now it's time to deploy, and you suddenly have to deal with servers, settings and a lot of complex architecture where small mistakes can have huge consequences. That's where Globe.dev comes in.

This article explores how Globe.dev aims to change that. It's a platform designed to make deploying Dart backend APIs more straightforward. We'll look at the typical challenges Dart developers face and how Globe.dev simplifies the process, enabling seamless deployment to a global audience.

The Challenge of Dart Backend Deployment

Deploying any backend application has its challenges, but Dart developers often face some unique obstacles. A lot of time can be spent on server setup, environment configurations, and scaling, which distracts developers from focusing on their code.

Some of the main issues in the Dart ecosystem:

  • Lack of First-Class Support: Many existing deployment platforms weren't built for Dart, leading to complicated deployment processes and workarounds.

  • Tooling Maturity: The Dart backend scene is still developing, and it doesn't have as many ready-made deployment tools as languages like Node.js or Python.

  • AOT Compilation: Dart's Ahead-of-Time (AOT) compilation, while improving performance, can sometimes make deployment more complex.

  • Newer Ecosystem: Server-side Dart development is relatively new, so the community is still working on establishing the best ways to handle deployment.

The Solution: Introducing Globe.dev

Globe.dev is a platform designed specifically for Dart and Flutter developers, making it easier to deploy applications. It simplifies the whole deployment process and helps developers deliver value faster.

Some key features:

  • Zero-Configuration Deployment: You can deploy your applications with a single command.

  • Developer-Friendly Experience: Globe.dev provides a smooth and intuitive experience, with clear documentation, a user-friendly CLI, and seamless integration with Dart and Flutter frameworks.

  • Global Scalability and Performance: Globe uses a globally distributed network to ensure your applications are fast, reliable, and accessible to users everywhere.

  • First-Class Dart Support: It is designed specifically for Dart and Flutter, providing seamless compatibility and optimal performance for Dart backend applications.

  • Built-in Monitoring and Analytics: The platform provides tools to monitor your application's performance and gather insights with built-in monitoring and analytics.

A practical demonstration using a TODO API

To show Globe.dev in action, let’s look at an example, deploying a simple TODO API that allows users to:

  • Create new todo items.

  • View a list of all the todo items.

  • Update existing todo items.

  • Delete the todo items.

This Todo API was built using Dart Frog, a fast and lightweight web framework for Dart. Dart Frog enables developers to create backend APIs using Dart, using the language's familiarity and performance. Before deploying this API on Globe.dev, you'll want to make sure it works correctly on your computer.

Local Development Setup

Dart and Dart Frog have made this local development easy. Developers can use the Dart CLI to run the API on their computer and tools like curl or Postman to test the API. This allows for quick testing and fixing of issues before deploying to a live environment. The following image shows the project being run using dart_frog dev and the base URL for testing the endpoints. The base URL obtained can then be used to test the API endpoints.

The image below shows the API endpoint test for a POST request, which was successful.

Now that you have confirmed the API endpoints work well, you can finally deploy our application on Globe.dev.

Deploying with Globe.dev: A Step-by-Step Guide

You can deploy your application in two ways. But before you do, you'll need a Globe.dev account.

Sign Up for a Globe.dev Account: First, create an account on the platform. If you have an account already, you can log in to your account.

As of the time of writing this article, Globe.dev offers two main ways to deploy your application:

Option 1: Deploy using Github Integration

Globe allows you to deploy your applications by seamlessly integrating with GitHub. To do this, you will need to first push your code to your GitHub account, then log in to the Globe dashboard.

  • Then you will click on the Create Project button and you will get this view below

  • If the current GitHub account isn’t the account you are deploying from, you can click on Configure the GitHub app at the bottom of the screen to add a new GitHub account to your Globe dashboard. When you do that, you will have this view below.

  • In this view, you will see all the organisations you have available in your GitHub account, you can select the account that has the repository you want to deploy the application.

  • Once you install, you will have this view now

  • Choose the specific GitHub repository that contains the application you want to deploy.

  • Now, let’s configure our project and set up the deployment settings. You will start with the import setting section. Here, you have to confirm the project name, the directory and the branch you are deploying from.

  • Next, you check the build settings section to ensure that the framework preset, build command and entry point are correct. Globe automatically detects what framework your application is built with and applies a framework preset. Supported framework presets are Dart Frog, Jaspr, Serverpod Mini and Flutter.

  • Next, you will check the build config section to check the Dart version and also enable build runner if you have build runner in your project pubspec.yaml file.

  • Finally, you have gotten to the last section, which is configuring environment variables. If you have any environment variables in your project, Globe allows you to store them secretly. If you do not have, you can skip the section.

  • After doing that and checking the sections again to ensure there are no mistakes, you can start the deployment process. Click on deploy and you will get this view once deployment is done.

Globe successful deployment

You can view your deployment or go to the dashboard after the deployment is successful. This method is really great If you are working in a team and it can be done by anyone, it is very straightforward.

Option 2: Deploy with Globe CLI

To deploy with Globe CLI, you will need to navigate to your project root directly in your preferred Integrated Development Environment (IDE) and deploy the application with a single command. Before the deployment can work in this method, you will need to activate the CLI and log in to your account.

  • Activate the Globe CLI by running this command:
dart pub global activate globe_cli
  • Then log in to your account with this command:
globe login
  • Now, you can deploy with this command:
globe deploy

Once you run the deploy command, your application will be deployed, and you can view it on the Globe dashboard. Although Globe has a unique deployment flow, you can deploy your application in preview and test that it works before deploying to production.

  • To deploy in preview, you will use this command:
globe deploy --no-prod
  • To deploy in production, you will use this command:
globe deploy --prod

Deploying With Your Own Domain

Globe.dev also empowers you to use a custom domain name for your deployed application, giving you more control over your application's branding and online presence. Instead of using the default Globe subdomain, you can link your own domain (e.g., your-app.com) to your Globe-hosted project.

Here's a breakdown of how it works:

  • Register Your Domain: You'll first need to register a domain name through an external domain provider (such as Namecheap, GoDaddy, or Google Domains).

  • Configure DNS Settings: Next, you'll configure your domain's DNS settings to point to Globe.

  • Add Your Domain to Globe: Finally, you'll add your domain to your Globe.dev project through the Globe dashboard.

Globe.dev handles the complexities of DNS management and automatically provides SSL (HTTPS) for your custom domain, ensuring secure access for your users.

To see a full breakdown of how to set up your custom domain successfully and link to your Globe project, check this documentation out.

Real-World Challenges and Solutions

Even with Globe.dev's simplified deployment, you might still encounter some common issues. These can include deployment failures due to incorrect settings, problems with environment variables, routing problems, or conflicts between different software packages. Globe provides detailed logs and documentation to help you identify and fix these issues. You can also use Dart's debugging tools and online resources for help.

For example, you might come across an issue where your deployment fails after running on CLI. What could be the issue? You will need to check your Globe dashboard to find out. I will share an image below of an issue I faced after deploying my application from Globe CLI.

From the image, the settings of my project deployment didn’t look right, so I checked the settings and noticed I didn’t have an entry point, there was no framework preset, so I included these things and redeployed, and the deployment was successful.

If you ask me why you should choose Globe, I would say:

  • It empowers developers to focus on building great applications and deploying them with confidence.

  • It simplifies the path to production.

  • Developers can leverage the full potential of Dart for backend development and deliver their applications to a global audience with ease.

For more information on Globe, check their documentation

52
Subscribe to my newsletter

Read articles from Mariam Hamzat directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mariam Hamzat
Mariam Hamzat

I'm an agile learner, mobile developer, tech lover and a mentor. I am currently interested in AI and Robotics