Prerequisites
- A Cloudflare account
- Wrangler CLI installed (
npm install -g wrangler) - A Remix application ready to deploy
Project Setup
Initialize a Workers project:wrangler.toml configuration:
Worker Entry Point
Create your Workers entry point:src/index.ts
Router Configuration
Your router works the same as on Node.js:router.ts
Development
Run locally with Wrangler:Deployment
Deploy to Cloudflare:Environment Variables & Secrets
Set environment variables:Durable Objects
For stateful applications, use Durable Objects:KV Storage
Bind KV namespaces inwrangler.toml:
D1 Database
For SQL databases, use Cloudflare D1:Limitations
- CPU time: 50ms on free tier, more on paid plans
- No Node.js built-ins (use web standards)
- Request size: 100MB max
Best Practices
- Keep workers lightweight
- Use KV for caching
- Minimize database queries
- Use Durable Objects for state
- Leverage edge caching
Related Documentation
Web Standards
Why Remix works perfectly on Workers
Fetch Router
Router API reference