Publish to Cloudflare¶
You can publish executable notebooks to Cloudflare Workers for free, after exporting your notebook to a WebAssembly notebook.
Export to WASM-powered HTML¶
Export your notebook to a self-contained HTML file that runs using WebAssembly with the flag --include-cloudflare
:
See our exporting guide for the full documentation.
Publish to a Cloudflare Worker¶
When you use the --include-cloudflare
flag, marimo creates two additional files in the parent directory of your output directory:
index.js
: A simple Cloudflare Worker script that serves your static assetswrangler.jsonc
: Configuration for Cloudflare's Wrangler CLI
To run locally, run:
To deploy to Cloudflare, run:
Need authentication or custom endpoints?
You can modify the index.js
to include authentication or custom endpoints. This allows you to:
- Add authentication logic to protect your notebook
- Create API endpoints that serve data from the same domain, avoiding CORS issues
Publish to Cloudflare Pages using GitHub¶
As an alternative to Cloudflare Workers, you can publish to Cloudflare Pages. To get started, create a new GitHub repository by visiting repo.new . After creating a new repository, go to your newly created project directory to prepare and push your local application to GitHub by running the following commands in your terminal:
cd output_dir
git init
git remote add origin https://github.com/<your-gh-username>/<repository-name>
git add .
git commit -m "Initial commit"
git branch -M main
git push -u origin main
To deploy your site to Pages:
- Log in to the Cloudflare Dashboard and select your account.
- In Account Home, select Workers & Pages > Create application > Pages > Connect to Git.
- Select the new GitHub repository that you created and, in the Set up builds and deployments section, provide the following information:
Project name output-dir
Production branch main
Framework preset None
Build command (optional) exit 0
Build output directory /
- Save and Deploy
Publish to Cloudflare Pages Manually¶
To deploy your site to Pages:
- Create zip of the folder "output_dir"
- Log in to the Cloudflare Dashboard and select your account.
- In Account Home, select Workers & Pages > Create application > Pages > Upload asset.
- Enter a project name then click Upload and select output_dir.zip .
- Save and Deploy