Deploying a Dart Frog Application
Dart Frog is a fast, minimalistic backend framework for Dart built on top of Shelf. It provides file-based routing, middleware support, and dependency injection for building efficient backend services. Globe automatically detects Dart Frog projects and applies the appropriate build and deployment settings. This page outlines requirements and deployment behaviour.
Project Setup
To create a new project using the Globe template:
globe create -t crud_rest_api_dartfrog
To create a Shelf project manually:
-
Install the Dart Frog CLI:
dart pub global activate dart_frog_cli
-
Create a new Dart Frog project:
dart_frog create my_dart_frog_app cd my_dart_frog_app
-
Test your application locally:
dart_frog dev
Deploying to Globe
Run the deployment command from your project root:
globe deploy
Globe automatically detects Dart Frog applications and applies the correct framework preset during deployment. No additional configuration is required.
How it works
Dart Frog uses a file-system-based routing approach:
- Routing: Dart Frog uses file-system-based routing. Files in the routes/ directory define endpoints.
- Middleware: Add interceptors for requests/responses via middleware files.
- Dependency Injection: Inject dependencies into handlers using the request context.
- Preset detection: Globe recognizes Dart Frog projects and handles all configs automatically.
Best practices
- Organize routes logically following REST API conventions for better maintainability.
- Use middleware for cross-cutting concerns like authentication and logging.
- Leverage dependency injection for configurable and testable services.
- Always listen to the PORT environment variable for Globe compatibility.
- Implement proper error handling with appropriate HTTP status codes.