Mastro 👨‍🍳 Docs

Search results

Blog Community GitHub   Stoat Chat   Discord   Bluesky

Deploy to production

Deploy static site

If you have a static site, you can deploy to GitHub Pages, Netlify, Cloudflare, Bunny, or any other CDN. You could even serve the files with a static file server like nginx.

Using a Continuous Integration / Continuous Delivery (CI/CD) service, such as GitHub Actions, ensures a reproducible environment (i.e. that it not only works on your computer), and makes sure that you haven’t forgotten to add any needed files to git. Basically, this is just running the following command on the CI/CD server instead of your laptop:

Depending on whether you use Deno or Node.js, and what your deploy target is, we may have exactly the right documentation for you. Otherwise you can probably adapt them to your use-case. If you run into problems, don’t hesitate to ask for help.

GitHub Pages Cloudflare Netlify
SSG with Deno docs docs docs
SSG with Node.js docs docs docs

Deploy server

Static site generation is the best setup – if you can get away with it. But sometimes, you want to do things that are only possible by dynamically generating pages on-demand by running a server.

GitHub Pages only offers static site hosting. To get a production server, use e.g. Deno Deploy, Railway, Render, Fly.io, Bunny Edge Scripting, or Cloudlfare Worker. You can run Mastro on any server that can run Deno, Node.js or Bun – e.g. via Docker.

Either way, it’s basically just running the following command on the server:

Deno
deno run --allow-read --allow-net --allow-env server.ts
Copied!
Node.js
node server.ts
Copied!
Bun
bun server.ts
Copied!

In production, be sure to run the above command, and not deno/pnpm/bun run start, which runs with the --watch flag that restarts the server on file changes – great for local development, but unnecessary in production.

Deno Deploy Render
Server with Deno docs docs
Server with Node.js - docs
Server with Bun - docs

We don’t have specific docs for every combination of JavaScript runtime and hosting provider (yet), but you can adapt the above to your provider. If you run into problems, don’t hesitate to ask for help.

Cloudflare Workers

Cloudflare Workers come with their own JavaScript runtime called workerd. They don’t support running on-demand code with Deno, Node.js or Bun. To run your server code on-demand on the edge using Cloudflare, use the Mastro template for Cloudflare Workers. Either via the template repo or:

pnpm create @mastrojs/mastro@0.1.6 --cloudflare
Copied!