CF-Changes Workers - Build TanStack Start apps with the Cloudflare Vite plugin

Cloudflare Reporting - Product Changelog

ENF News Bot

Automated News Bot
Joined
Apr 15, 2022
Messages
4,195
The Cloudflare Vite plugin now supports TanStack Start ↗︎ apps. Get started with new or existing projects.

New projects​

https://developers.cloudflare.com/changelog/rss/#new-projects

Create a new TanStack Start project that uses the Cloudflare Vite plugin via the create-cloudflare CLI:

npmyarnpnpm

npm create cloudflare@latest -- my-tanstack-start-app --framework=tanstack-start



yarn create cloudflare my-tanstack-start-app --framework=tanstack-start



pnpm create cloudflare@latest my-tanstack-start-app --framework=tanstack-start


Existing projects​

https://developers.cloudflare.com/changelog/rss/#existing-projects

Migrate an existing TanStack Start project to use the Cloudflare Vite plugin:

  1. Install @cloudflare/vite-plugin and wrangler
npmyarnpnpmbun

npm i -D @cloudflare/vite-plugin wrangler



yarn add -D @cloudflare/vite-plugin wrangler



pnpm add -D @cloudflare/vite-plugin wrangler



bun add -d @cloudflare/vite-plugin wrangler


  1. Add the Cloudflare plugin to your Vite config
vite.config.tsts

Code:
import { defineConfig } from "vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact from "@vitejs/plugin-react";
import { cloudflare } from "@cloudflare/vite-plugin";

export default defineConfig({
	plugins: [
		cloudflare({ viteEnvironment: { name: "ssr" } }),
		tanstackStart(),
		viteReact(),
	],
});
  1. Add your Worker config file

Code:
{
	"$schema": "./node_modules/wrangler/config-schema.json",
	"name": "my-tanstack-start-app",
	// Set this to today's date
	"compatibility_date": "2026-11-14",
	"compatibility_flags": [
		"nodejs_compat"
	],
	"main": "@tanstack/react-start/server-entry"
}

Code:
"$schema" = "./node_modules/wrangler/config-schema.json"
name = "my-tanstack-start-app"
# Set this to today's date
compatibility_date = "2026-11-14"
compatibility_flags = [ "nodejs_compat" ]
main = "@tanstack/react-start/server-entry"
  1. Modify the scripts in your package.json
package.jsonjson

Code:
{
	"scripts": {
		"dev": "vite dev",
		"build": "vite build && tsc --noEmit",
		"start": "node .output/server/index.mjs",
		"preview": "vite preview",
		"deploy": "npm run build && wrangler deploy",
		"cf-typegen": "wrangler types"
	}
}

See the TanStack Start framework guide for more info.

Continue reading...
 
Back
Top