🕹 Jaspr CLI
Jaspr comes with a cli tool to create, serve and build your web app.
jaspr createwill create a new jaspr project. The cli will prompt you for a project name and template to use.
jaspr servewill serve the web-app in the current directory, including hot-reloading.
jaspr buildwill build the web-app containing the static web assets (compiled js, html, ...) and the server executable.
jaspr generatewill generate all routes of your website at build time and build the web-app as a static site.
📟 Execution Mode#
Jaspr is a full-stack web framework, meaning it can run both on the server and the client. Depending on what you want to build you can choose how your app should be built and executed using jaspr.
Server-side Rendering with client-side hydration: In the default mode jaspr runs both on the server and client. It renders your html on the server including any dynamic data from an api or database and then hydrates that html on the client in order to make it interactive. This is the default mode for the
Client-side only: If you want, you can skip the server part of jaspr completely and use it as a client-side only framework. This way you can deploy your built app to any static hosting provider (like firebase hosting) without needing an extra server. To use it like this, simply use the
clienttemplate when creating a new project.
Server-side only: If you are dealing with a fully static website without needing any interactivity through js, you can also use jaspr as a purely server-side rendering framework. To set this up, use the
Static site generation: Jaspr can also perform static site generation, meaning it can generate static pages at build time from your server-side components. This can be used with any project that has server-side rendering setup, simply by using
jaspr generateinstead of
jaspr buildwhen building and deploying your app.
When generating a new project, you can choose from one of several templates to get started quickly. The templates showcase common configurations of jaspr and provide a ready-to use setup.
Templates do not lock you into a specific configuration. Starting from one template you can easily modify your code to behave as any other template along the way. So if you are not sure yet what to pick, just start with the recommended 'basic' template.
The recommended template for a standard jaspr app. It gives you a pure-dart web app with ssr & automatic client hydration.
Similar to the basic template, but with an additional
styles.css file in case
you prefer to write your template in html and global styles in css.
A pure client-side app without ssr. Allows your site to be deployed to a static file hosting provider, like Firebase Hosting.
A purely server-side rendered app without client hydration. This means you will have no generated js and therefore no client interaction, but a completely static site, like a simple blog.
When it's time to deploy your application, you can build it using the following command:
This will build the app inside the
You can choose whether to build a standalone executable or an aot or jit snapshot with the
If you are using jaspr with server-side rendering (default), you can run your app by starting the
build/jaspr/app (when you deploy your app, make sure to also copy the
next to the executable). If you build with
uses-ssr: false, you can deploy the files inside
build/jaspr directory to any static hosting provider.