Quickstart
Get up and running with Jaspr in just a few minutes. This guide will walk you through installation, creating your first project, and running the development server.Installation
Install Dart
Jaspr requires Dart SDK 3.8.0 or higher. If you don’t have Dart installed, get it from dart.dev.Verify your installation:Expected output:
Create Your First Project
Create a new project
Use the The CLI will prompt you for:
jaspr create command to scaffold a new project:- Project name: Confirm or change the project name
- Setup options: Choose between different project templates (basic, with routing, etc.)
The default template includes a basic setup with server-side rendering configured.
Run the Development Server
Open in browser
Navigate to
http://localhost:8080 in your web browser. You should see your app running!Build Your First Component
Let’s create a simple interactive component to understand Jaspr’s component model.Create a counter component
Create a new file
lib/components/counter.dart:The
@client annotation tells Jaspr to make this component interactive by running it on the client side.Understanding Components
Jaspr has three main types of components, similar to Flutter widgets:StatelessComponent
A basic component with a single
build() method. Use for UI that doesn’t change.StatefulComponent
A component that holds state and can trigger rebuilds with
setState(). Use for interactive UI.InheritedComponent
A component that provides data to its descendants. Use for sharing state down the tree.
HTML Elements as Components
Jaspr provides all HTML elements as components:CLI Commands Reference
Here are the essential Jaspr CLI commands:jaspr create
Creates a new Jaspr project with interactive prompts for configuration.
jaspr serve
Serves your website with hot-reload for development.
--portor-p: Specify the port (default: 8080)--host: Specify the host (default: localhost)
jaspr build
Builds your website for production, creating static assets and the optional server executable.
build/jaspr directory:
- Compiled JavaScript files
- HTML files
- CSS and other assets
- Server executable (if using SSR)
Next Steps
Now that you have a running Jaspr application, here’s what to explore next:Components
Learn about component lifecycle, state management, and composition
Styling
Discover how to style your components with CSS and inline styles
Routing
Add navigation to your app with jaspr_router
Server-Side Rendering
Deep dive into SSR and client-server state synchronization
Troubleshooting
Hot-reload not working
If hot-reload isn’t working:- Make sure you’re running
jaspr serve(notjaspr build) - Check the terminal for any error messages
- Try stopping the server (Ctrl+C) and starting again
Build errors
If you encounter build errors:- Run
dart pub getto ensure dependencies are installed - Check that your Dart SDK version meets the minimum requirement (3.8.0+)
- Clear the build cache:
rm -rf .dart_tool/build
Component not rendering
If a component isn’t rendering:- Check that you’re importing the component correctly
- For interactive components, ensure you’ve added the
@clientannotation - Check the browser console for JavaScript errors