[ Web Proxy ]
URL:
Viewing: https://developers.cloudflare.com/workers/vite-plugin/get-started/ [Back]  [Original]

Get started Cloudflare Workers docsSkip to content
SearchCtrlKLog in
  1. Home
  2. /Workers
  3. /Vite plugin
  4. /Get started

Get started

Last updated Apr 23, 2026Copy as MarkdownView as MarkdownAgent setup
OverviewStart with a basic package.jsonInstall the dependenciesCreate your Vite config file and include the Cloudflare pluginCreate your Worker config fileCreate your Worker entry fileDev, build, preview and deploy

Note

This guide demonstrates creating a standalone Worker from scratch. If you would instead like to create a new application from a ready-to-go template, refer to the TanStack Start, React Router, React or Vue framework guides.

Start with a basic package.json

package.jsonjson
{
	"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"
	}
}

Note

Ensure that you include "type": "module" in order to use ES modules by default.

Install the dependencies

npmyarnpnpmbun
npm i -D vite @cloudflare/vite-plugin wrangler

Create your Vite config file and include the Cloudflare plugin

vite.config.tsts
import { defineConfig } from "vite";
import { cloudflare } from "@cloudflare/vite-plugin";

export default defineConfig({
	plugins: [cloudflare()],
});

The Cloudflare Vite plugin doesn't require any configuration by default and will look for a wrangler.jsonc, wrangler.json or wrangler.toml in the root of your application.

Refer to the API reference for configuration options.

Create your Worker config file

{
	"$schema": "./node_modules/wrangler/config-schema.json",
	"name": "cloudflare-vite-get-started",
	// Set this to today's date
	"compatibility_date": "2026-08-19",
	"main": "./src/index.ts"
}
"$schema" = "./node_modules/wrangler/config-schema.json"
name = "cloudflare-vite-get-started"
# Set this to today's date
compatibility_date = "2026-08-19"
main = "./src/index.ts"

The name field specifies the name of your Worker. By default, this is also used as the name of the Worker's Vite Environment (see Vite Environments for more information). The main field specifies the entry file for your Worker code.

For more information about the Worker configuration, see Configuration.

Create your Worker entry file

src/index.tsts
export default {
	fetch() {
		return new Response(`Running in ${navigator.userAgent}!`);
	},
};

A request to this Worker will return 'Running in Cloudflare-Workers!', demonstrating that the code is running inside the Workers runtime.

Dev, build, preview and deploy

You can now start the Vite development server (npm run dev), build the application (npm run build), preview the built application (npm run preview), and deploy to Cloudflare (npm run deploy).

PreviousOverviewNextTutorial - React SPA with an API

Was this helpful?

YesNo
Edit pageReport issue
[]

Web Proxy Viewer  |  New URL  |  Original Page