Cloudflare Workers
Learn how to deploy your app to Cloudflare Workers.
Setup
- Sign up / Log in to Cloudflare.
- Set up Hyperdrive (for database connections):
- In the Cloudflare dashboard, go to Storage & Databases → Hyperdrive.
- Click Create Hyperdrive and connect it to your database (e.g., Postgres, MySQL).
- Once created, copy the Hyperdrive ID.
- Run the following command in your project
Terminal
mv wrangler.example.toml wrangler.toml - Set it to wrangler.toml:
wrangler.toml
[[hyperdrive]] binding = "HYPERDRIVE" id = "your-hyperdrive-id"
- Set nitro preset in environment variable:.env
NITRO_PRESET="cloudflare_module" - Commit changes and push to your repository.
- Deploy via Cloudflare:
- Go to Workers & Pages → Create Application → Create Worker.
- Connect your GitHub repository.
- Set the build command to:
npm run build - Add environment variables (
.env.localvalues). - Click Deploy to build and launch
- Access and verify your live site at the Cloudflare Workers URL.
- Auto-deploy happens on every push to the main branch.
- Check logs in Cloudflare dashboard if something fails during build or runtime.