Skip to content

Configuration ​

Configure Aim CLI via pubspec.yaml, under a top-level aim: key.

Settings ​

KeyUsed byDescriptionDefault
targetaim dev, aim buildWhere the app runs: server, workers, supabase or functionsserver
entryaim dev, aim buildEntry point. No effect for target: functions — Firebase resolves the entry point itselfbin/server.dart for server, or lib/main.dart for workers/supabase
envaim devEnvironment variables passed to the appnone
database.urlaim db:*Database connection URLrequired by aim db:*
database.schemaaim db:generatePath to table definitions, a file or a directorylib/schema

Values under env and database go through variable expansion, so secrets stay out of the file.

Basic Configuration ​

yaml
name: my_app
description: My Aim application

dependencies:
  aim_server: ^0.4.0

aim:
  entry: bin/server.dart

Target ​

aim.target selects where the application runs. It changes what aim dev and aim build do and the default entry point.

targetRuntimeaim devaim buildDefault entry
server (default)Dart VM with aim_serverdart run with restart on changedart compile exe → build/serverbin/server.dart
workersCloudflare workerd with aim_workersdart compile wasm + npx wrangler@4 dev, recompiles on changedart compile wasm → build/workers/lib/main.dart
supabaseSupabase Edge Functions with aim_denodart compile wasm + supabase functions serve, starting the local Supabase stack first if it is not already running, recompiles on change without restarting the serve processdart compile wasm → supabase/functions/<name>/lib/main.dart
functionsCloud Functions for Firebase with aim_functionsfirebase emulators:start --only functions; the emulator rebuilds on changenothing — firebase deploy --only functions compilesn/a — Firebase resolves the entry point itself, not aim

edge is no longer a valid value: the Cloudflare target and its dependency were renamed to workers/aim_workers. A pubspec.yaml still saying aim.target: edge fails aim dev/aim build with an error naming the replacement.

yaml
aim:
  target: workers
  entry: lib/main.dart

aim.env is not applied for target: workers; declare vars and bindings in wrangler.jsonc instead and read them with c.env. It is likewise not applied for target: supabase; set variables with supabase secrets set, or in supabase/functions/.env for local development, and read them with c.env. For target: functions, aim.env is passed to the Firebase emulator process, which the function process it spawns inherits.

Environment Variables ​

Static Values ​

yaml
aim:
  entry: bin/server.dart
  env:
    PORT: "8080"
    HOST: "0.0.0.0"
    ENV: "development"

Environment Variable Expansion ​

You can expand system environment variables:

yaml
aim:
  env:
    DATABASE_URL: ${DATABASE_URL}
    JWT_SECRET: ${JWT_SECRET}
    API_KEY: ${API_KEY}

Default Values ​

Default values when environment variables are not set:

yaml
aim:
  env:
    PORT: ${PORT:8080}
    HOST: ${HOST:0.0.0.0}
    DATABASE_URL: ${DB_URL:postgresql://localhost/dev}

Combined Example ​

yaml
aim:
  entry: bin/server.dart
  env:
    # Static values
    ENV: "development"

    # With defaults
    PORT: ${PORT:8080}
    HOST: ${HOST:0.0.0.0}

    # Required (no default)
    DATABASE_URL: ${DATABASE_URL}
    JWT_SECRET: ${JWT_SECRET}

Database ​

aim.database configures the aim db:* commands.

yaml
aim:
  database:
    url: ${DATABASE_URL:postgresql://localhost:5432/mydb}
    schema: lib/schema
KeyDescription
urlConnection URL used by db:migrate, db:rollback, db:reset and db:status
schemaWhere db:generate reads table definitions from. --path overrides it

url is expanded like aim.env, so the connection string does not have to be committed:

bash
export DATABASE_URL="postgresql://user:pass@prod-host:5432/mydb"
aim db:migrate

A ${VAR} that is not set and has no default reads as not configured, and the command stops with Database URL not found instead of dialling an empty address.

Variable Expansion Formats ​

FormatDescription
$VAR_NAMESimple expansion
${VAR_NAME}Braces expansion
${VAR_NAME:default}With default value

Expansion applies to the values under aim.env and aim.database.

How It Works ​

When running aim dev:

  1. Load aim.env from pubspec.yaml
  2. Expand ${VAR} with system environment variables
  3. Merge with existing environment variables
  4. Pass to application

Example Workflow ​

Development ​

yaml
# pubspec.yaml
aim:
  entry: bin/server.dart
  env:
    PORT: ${PORT:3000}
    DATABASE_URL: ${DB_URL:postgresql://localhost/dev}
    DEBUG: "true"
bash
# Uses defaults
aim dev
# PORT=3000, DATABASE_URL=postgresql://localhost/dev, DEBUG=true

Production ​

bash
# Override with environment variables
export PORT=8080
export DB_URL="postgresql://prod-server/mydb"
aim dev
# PORT=8080, DATABASE_URL=postgresql://prod-server/mydb, DEBUG=true

Entry Point Resolution ​

This applies to target: server, target: workers and target: supabase. For target: functions, none of it applies — firebase emulators:start and firebase deploy resolve the entry point themselves, so --entry and aim.entry are silently ignored.

Entry point is determined in this order:

  1. --entry option (aim dev --entry bin/api.dart)
  2. aim.entry in pubspec.yaml
  3. Target default: bin/server.dart for server, lib/main.dart for workers and supabase

Watch Directories ​

Directories watched by aim dev:

  • Default: lib, bin
  • Customizable with --watch option
bash
aim dev --watch lib,bin,routes,config

Next Steps ​

Released under the MIT License.