Local development
When building projects on Cloudflare Workers, you have two options for local development:
- Wrangler, using the built-in
wrangler dev
command. - Vite ↗, using the Cloudflare Vite plugin.
Both Wrangler and the Vite plugin use Miniflare to provide an accurate local simulation of the Cloudflare Workers runtime, (workerd
↗). If you need to develop with remote resources, Wrangler is the only option that provides remote development with the wrangler dev --remote
command.
To install Wrangler ↗, ensure you have Node.js ↗ and npm ↗ installed, preferably using a Node version manager like Volta ↗ or nvm ↗.
npm install wrangler --save-dev
yarn add --dev wrangler
To start a development server using Wrangler, run the following:
npx wrangler dev
pnpm wrangler dev
yarn wrangler dev
To install the Cloudflare Vite plugin, first start with a simple package.json
{ "name": "cloudflare-vite-get-started", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite dev", "build": "vite build", "preview": "npm run build && vite preview", "deploy": "npm run build && wrangler deploy" }}
Then, install the necessary development depenencies:
npm i -D vite @cloudflare/vite-plugin wrangler
pnpm add -D vite @cloudflare/vite-plugin wrangler
yarn add -D vite @cloudflare/vite-plugin wrangler
This command will install vite
, along with @cloudflare/vite-plugin
and wrangler
as devDependencies
in your package.json
.
You can then start a development server by running:
npm run dev
pnpm run dev
yarn run dev
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark