Skip to content

Commit 6286e49

Browse files
committed
add instructions on deploying existing tanstack app
1 parent 976e08e commit 6286e49

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

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

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ import {
1414
InlineBadge,
1515
Render,
1616
PackageManagers,
17+
Steps,
1718
} from "~/components";
1819

19-
In this guide, you will create a new [TanStack Start](https://tanstack.com/start) application and deploy it to Cloudflare Workers.
20+
[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.
2021

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

2328
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.
2429

@@ -36,6 +41,60 @@ After setting up your project, change your directory by running the following co
3641
cd my-tanstack-start-app
3742
```
3843

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

41100
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)