70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
38 lines
1.7 KiB
Markdown
38 lines
1.7 KiB
Markdown
# `@cloudflare/vite-plugin`
|
|
|
|
The Cloudflare Vite plugin enables a full-featured integration between [Vite](https://vite.dev/) and the [Workers runtime](https://developers.cloudflare.com/workers/runtime-apis/).
|
|
Your Worker code runs inside [workerd](https://github.com/cloudflare/workerd), matching the production behavior as closely as possible and providing confidence as you develop and deploy your applications.
|
|
|
|
```ts
|
|
// vite.config.ts
|
|
|
|
import { defineConfig } from "vite";
|
|
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
|
|
export default defineConfig({
|
|
plugins: [cloudflare()],
|
|
});
|
|
```
|
|
|
|
## Documentation
|
|
|
|
Full documentation can be found [here](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
|
|
## Features
|
|
|
|
- Uses the Vite [Environment API](https://vite.dev/guide/api-environment) to integrate Vite with the Workers runtime
|
|
- Provides direct access to [Workers runtime APIs](https://developers.cloudflare.com/workers/runtime-apis/) and [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/)
|
|
- Builds your front-end assets for deployment to Cloudflare, enabling you to build static sites, SPAs, and full-stack applications
|
|
- Official support for [TanStack Start](https://tanstack.com/start/) and [React Router v7](https://reactrouter.com/) with server-side rendering
|
|
- Leverages Vite's hot module replacement for consistently fast updates
|
|
- Supports `vite preview` for previewing your build output in the Workers runtime prior to deployment
|
|
|
|
## Use cases
|
|
|
|
- [TanStack Start](https://tanstack.com/start/)
|
|
- [React Router v7](https://reactrouter.com/)
|
|
- Support for more full-stack frameworks is coming soon
|
|
- Static sites, such as single-page applications, with or without an integrated backend API
|
|
- Standalone Workers
|
|
- Multi-Worker applications
|