Project Configuration
The configuration options for a Jaspr project.
Each Jaspr project is a normal Dart project including a pubspec.yaml file and lib/ directory.
The project-wide Jaspr configuration is specified in pubspec.yaml under the jaspr option:
name: my_project
...
jaspr:
mode: server
port: 8080
flutter: plugins
There are currently the following configuration options available:
modeEnumrequiredSets the Rendering Mode for your project. Either static, server or client.
portintoptionalOnly applicable in "static" or "server" mode.
Specifies the target port to use when serving your project. This is optional and defaults to "8080" if not set. Can be overridden by the --port flag with jaspr serve.
flutterEnumoptionalSpecifies the Flutter support for your project.
embedded: Enables Flutter embedding support, allowing you to use Flutter widgets inside Jaspr components.plugins: Enables Flutter plugin support, allowing you to use Flutter plugins that provide web support inside your project.noneor omitted: No Flutter support.
Using either embedded or plugins requires the Flutter SDK to be installed and available in your system PATH, as well as a dependency on build_web_compilers with a minimum version constraint of 4.4.6 or higher.
Project Structure
The following is the recommended project structure for any Jaspr website. The concrete files vary slightly depending on your chosen Rendering Mode.
โโโ lib/
โ โโโ components/ // Shared components
โ โ โโโ counter.dart
โ โ โโโ ...
โ โโโ pages/ // The pages of your website
โ โ โโโ home.dart
โ โ โโโ ...
โ โโโ app.dart // The main app component, usually containing the Router
โ โโโ ...
โ โโโ main.client.dart // The client entrypoint, for all modes, optional
โ โโโ main.client.options.dart // Auto-generated by Jaspr
โ โโโ main.server.dart // The server entrypoint, only for server or static mode
โ โโโ main.server.optionsdart // Auto-generated by Jaspr
โโโ web/. // Static assets
โ โโโ images/
โ โ โโโ ...
โ โโโ styles.css // Usually only for client mode
โ โโโ index.html // The index file, only for client mode
โโโ pubspec.lock
โโโ pubspec.yaml
-
The
libdirectory contains all your usual dart code, including components, pages, routes etc. depending on your architecture. -
The
lib/main.server.dartfile is the entry point for your server application. It callsrunApp()and provides your root document component. Only needed for static or server mode.You can also have other
*.server.dartfiles and choose one with--inputflag when running your project. -
The
lib/main.client.dartfile is the entrypoint for your client environment. It callsrunApp()and either provides your root component (in client mode), or theClientApp()component (in static or server mode) which hydrates all@clientcomponents.You can also have other
*.client.dartfiles. Any*.client.dartfile insidelib/is automatically compiled to JavaScript. In static and server mode, any file that has a peer<filename>.server.dartfile is automatically loaded as a script tag. In client mode, or for using non-peer*.client.dartfiles you need to manually include a script tag pointing to<filename>.client.dart.jsin your page. -
The
*.<server|client>.options.dartfiles are auto-generated by Jaspr's tooling. It exposes a top-leveldefaultServerOptionsordefaultClientOptionsthat you should provide to theJaspr.initializeApp(options: ...)call inside*.<server|client>.dart. -
The
webdirectory contains any static assets you want to access from your website, like images or fonts. Files inside this directory are later accessible through their relative url, e.g.<domain>/images/logo.png. -
The
web/index.htmlfile (along with other html and css files) is only needed in client mode and contains the static markup and styling for your website.

