Project Structure
The structure of a new Jaspr project.
Each Jaspr project is a normal Dart project including a pubspec.yaml file and lib/ directory.
Depending on your chosen Rendering Mode and Hydration settings, your Jaspr project will have a slightly different project structure.
Static/Server Mode with Automatic Hydration
โโโ lib/
โ   โโโ components/
โ   โ   โโโ counter.dart
โ   โ   โโโ ...
โ   โโโ pages/
โ   โ   โโโ home.dart
โ   โ   โโโ ...
โ   โโโ app.dart
โ   โโโ ...
โ   โโโ jaspr_options.dart
โ   โโโ main.dart
โโโ web/
โ   โโโ images/
โ       โโโ ...
โโโ pubspec.lock
โโโ pubspec.yaml
- 
The
libdirectory contains all your usual dart code, including components, pages, routes etc. depending on your architecture. - 
The
lib/main.dartfile is the entry point for your server application. It callsrunApp()and provides your root document component.Any component annotated with
@clientthat is built during pre-rendering will automatically be hydrated on the client. - 
The optional
lib/jaspr_options.dartis auto-generated by Jaspr's tooling. It exposes a top-leveldefaultJasprOptionsthat you should provide to theJaspr.initializeApp(options: ...)call insidelib/main.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. 
Static/Server Mode with Manual Hydration
โโโ lib/
โ   โโโ components/
โ   โ   โโโ counter.dart
โ   โ   โโโ ...
โ   โโโ pages/
โ   โ   โโโ home.dart
โ   โ   โโโ ...
โ   โโโ app.dart
โ   โโโ ...
โ   โโโ main.dart
โโโ web/
โ   โโโ images/
โ   โ   โโโ ...
โ   โโโ main.dart
โโโ pubspec.lock
โโโ pubspec.yaml
- 
The
libdirectory contains all your usual dart code, including components, pages, routes etc. depending on your architecture. - 
The
lib/main.dartfile is the server entry point for your application. It callsrunApp()and provides your root document component. - 
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.Additionally, any
.dartfile in here will be compiled to js and accessible through<domain>/<filename>.dart.js. - 
The
web/main.dartfile is the client entry point for your application. It callsrunApp()and provides the main app component, hydrating the pre-rendered html created by the server. 
Client Mode
โโโ lib/
โ   โโโ components/
โ   โ   โโโ counter.dart
โ   โ   โโโ ...
โ   โโโ pages/
โ   โ   โโโ home.dart
โ   โ   โโโ ...
โ   โโโ app.dart
โโโ web/
โ   โโโ images/
โ   โ   โโโ ...
โ   โโโ index.html
โ   โโโ styles.css
โ   โโโ main.dart
โโโ pubspec.lock
โโโ pubspec.yaml
- 
The
libdirectory contains all your usual dart code, including components, pages, routes etc. depending on your architecture. - 
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.Additionally, any
.dartfiles in here will be compiled to js and accessible through<domain>/<filename>.dart.js. - 
The
web/index.htmlfile (along with other html and css files) contains the static markup and styling for your website. - 
The
web/main.dartfile is the entry point for your application. It callsrunApp()and provides the main app component. 

