Skip to content

Commit 3878f1f

Browse files
authored
Add instructions on deploying existing tanstack app (#26165)
* add instructions on deploying existing tanstack app * use wranglerconfig component
1 parent b9d3a43 commit 3878f1f

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

src/content/docs/workers/framework-guides/web-apps/tanstack-start.mdx

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ import {
1414
InlineBadge,
1515
Render,
1616
PackageManagers,
17+
Steps,
18+
WranglerConfig,
1719
} from "~/components";
1820

19-
In this guide, you will create a new [TanStack Start](https://tanstack.com/start) application and deploy it to Cloudflare Workers.
21+
[TanStack Start](https://tanstack.com/start) is a full-stack framework for building web applications. It comes with features like server-side rendering, streaming, server functions, bundling, and more. In this guide, you learn to deploy a TanStack Start application to Cloudflare Workers.
2022

21-
## 1. Set up a new project
23+
## 1. Set up a TanStack Start project
24+
25+
If you have an existing TanStack Start application, skip to the [Configuring an existing TanStack Start application](#configuring-an-existing-tanstack-start-application) section.
26+
27+
### Creating a new TanStack Start application
2228

2329
Use the [`create-cloudflare`](https://www.npmjs.com/package/create-cloudflare) CLI (C3) to set up a new project. C3 will create a new project directory, initiate TanStack Start's official setup tool, and provide the option to deploy instantly.
2430

@@ -36,6 +42,57 @@ After setting up your project, change your directory by running the following co
3642
cd my-tanstack-start-app
3743
```
3844

45+
### Configuring an existing TanStack Start application
46+
47+
If you have an existing TanStack Start application, you can configure it to run on Cloudflare Workers by following these steps:
48+
49+
<Steps>
50+
1. Add the `wrangler.jsonc` configuration file to the root of your project with the following content:
51+
<WranglerConfig>
52+
```toml
53+
name = "<YOUR_PROJECT_NAME>"
54+
compatibility_date = "2025-09-02"
55+
compatibility_flags = ["nodejs_compat"]
56+
main = "@tanstack/react-start/server-entry"
57+
[observability]
58+
enabled = true
59+
```
60+
</WranglerConfig>
61+
62+
2. Install `wrangler` as a development dependency:
63+
64+
<PackageManagers dev pkg="wrangler@latest" />
65+
66+
3. Install the `@cloudflare/vite-plugin` package as a dependency:
67+
68+
<PackageManagers type="add" pkg="@cloudflare/vite-plugin@latest" />
69+
70+
4. Update your `vite.config.ts` file to include the Cloudflare Vite plugin:
71+
72+
```ts title="vite.config.ts"
73+
import { defineConfig } from "vite";
74+
import { cloudflare } from "@cloudflare/vite-plugin";
75+
...
76+
77+
export default defineConfig({
78+
plugins: [cloudflare({ viteEnvironment: { name: 'ssr' } }), ...],
79+
// ... other configurations
80+
});
81+
```
82+
83+
5. Update the `scripts` section of your `package.json` file to include the following commands:
84+
85+
```jsonc title="package.json"
86+
"scripts": {
87+
...
88+
"deploy": "npm run build && wrangler deploy",
89+
"preview": "npm run build && vite preview",
90+
"cf-typegen": "wrangler types"
91+
}
92+
```
93+
94+
</Steps>
95+
3996
## 2. Develop locally
4097

4198
After you have created your project, run the following command in the project directory to start a local development server. This will allow you to preview your project locally during development.

0 commit comments

Comments
 (0)