Skip to content
Cloudflare Docs

Local development

When building projects on Cloudflare Workers, you have two options for local development:

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.

Install and start your development server

Wrangler

Installation

To install Wrangler, ensure you have Node.js and npm installed, preferably using a Node version manager like Volta or nvm.

Terminal window
npm install wrangler --save-dev

Start a development server

To start a development server using Wrangler, run the following:

Terminal window
npx wrangler dev

Vite Plugin

Installation

To install the Cloudflare Vite plugin, first start with a simple package.json

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:

Terminal window
npm i -D vite @cloudflare/vite-plugin wrangler

This command will install vite, along with @cloudflare/vite-plugin and wrangler as devDependencies in your package.json.

Start a development server

You can then start a development server by running:

Terminal window
npm run dev