Deployment targets

Rakkas has first-class support for deploying on Node, Vercel, Netlify, and Cloudflare Workers, as well as static file servers. The build CLI command accepts a --deployment-target option (-d for short) to specify the deployment target. Its value can be node, static, vercel, netlify, or cloudflare-workers. The default value is node.


When you build your application for Node, Rakkas will generate a Node application with an entry point in dist/server/index.js, so you can start the server with node dist/server. The generated server doesn't reference any external modules, so you only need to install the dependencies used in your own code. In particular, rakkasjs and @rakkasjs/cli don't need to be installed

You can customize the runtime behavior of the server with the following environment variables:

TRUST_FORWARDED_ORIGINWhether to trust x-forwarded-* headers
HOSTServer host
DISABLE_STATIC_SERVERWhether to disable serving of static assets

The server can serve the client assets on its own (using sirv) but if you choose to use your reverse proxy (e.g. NGINX) to serve them instead, they reside in the dist/client directory. In this case you may set the DISABLE_STATIC_SERVER environment variable to 1 to disable the static asset server which may reduce the start-up time of the server and its memory footprint.


If your entire application is suitable for pre-rendering, you can build a static site with rakkas build -d static. The generated site will be in the dist directory, so you can preview it with, e.g., npx sirv dist. A static site doesn't need a Node.js server, you can serve it from a CDN or a static file server like Github pages.

The default value for the prerender configuration option will be set as ["/"] instead of [] and the default value for the prerender property of load function results and endpoint responses will be set to true when using the static deployment target. In other words, pre-rendering will be opt-out instead of opt-in. Pages and API routes that weren't pre-rendered will not be available.

Page redirections will be rendered as HTML pages with a <meta http-equiv="refresh" content="0; url=..."> tag.


If you add a build or vercel-build script to your package.json with the content rakkas build -d vercel, you can use the Vercel CLI or their git integration to deploy your app.

Vercel can't automatically detect a Rakkas application as of yet but Rakkas uses the file system API, so you can just use the default values for build and development settings.


Create a netlify.toml file in the root of your project with the following content:

command = "npx rakkas build -d netlify"
publish = "netlify/static"

and use the Netlify CLI to deploy your app. You can also link your git repository to Netlify to automatically deploy your app when you push to your repository.

Cloudflare Workers

Create a wrangler.toml file in the root of your project like the following:

compatibility_date = "2021-11-01"
compatibility_flags = []
name = "<the name of your app>"
route = ''
site = {bucket = "cloudflare/static", entry-point = "cloudflare"}
type = "javascript"
usage_model = ''
workers_dev = true
zone_id = ''

command = "npx rakkas build -d cloudflare-workers"

format = "service-worker"

and use wrangler CLI tool to deploy your app. miniflare is also supported (use miniflare cloudflare/index.js)