Getting Started
Get your first Spark application running in under a minute.
Prerequisites
Ensure you have the Dart SDK installed (version 3.0 or later).
Install the CLI
Install the Spark CLI globally:
dart pub global activate spark_cliCreate a Project
Create a new Spark project:
spark init my_app
cd my_appStart Development
Run the development server with hot reload:
spark devVisit `http://localhost:8080` to see your app. The server automatically reloads when you save changes.
If file watching doesn't work (e.g., in WSL or Docker), use polling mode:
spark dev --pollProject Structure
The CLI generates a project with this structure:
my_app/
├── bin/
│ └── server.dart # Server entry point
├── lib/
│ ├── pages/ # Page files
│ ├── components/ # Web components
│ └── endpoints/ # API routes
└── pubspec.yamlBuild for Production
Build a standalone executable for deployment:
spark buildOptions:
- `--output, -o <path>` - Output directory (default: `build`)
- `--verbose, -v` - Show detailed build output
- `--no-clean` - Skip cleaning build directory
The build process:
- Runs code generation (build_runner)
- Compiles server to native executable
- Compiles web assets to JavaScript
- Copies static assets from `web/assets/`
Output structure:
build/
├── bin/
│ └── server # Native executable
├── lib/ # Native libraries (if any)
└── web/
├── *.dart.js # Compiled JS
└── assets/ # Static filesRun `./build/bin/server` to start your production server without the Dart SDK.