You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this guide, you will create a new [TanStack](https://tanstack.com/) application and deploy to Cloudflare Workers (with the new [Workers Assets](/workers/static-assets/)).
11
11
@@ -21,25 +21,25 @@ npm install
21
21
22
22
## Develop locally
23
23
24
-
```sh
25
-
npm run dev
26
-
```
24
+
<PackageManagerstype="run"args={"dev"} />
27
25
28
26
## Preparing for Deployment to Cloudflare Workers
29
27
28
+
To prepare your TanStack application for deployment to Cloudflare Workers, follow three main steps: install the `unenv` package, modify the `app.config.ts` file, and add either a `wrangler.jsonc` or `wrangler.toml` file.
29
+
30
30
### Install `unenv` package
31
31
32
32
[`unenv`](https://github.com/unjs/unenv) is a package that normalizes runtime environments across Node.js, browsers, and edge runtimes like Cloudflare Workers. It’s essential for TanStack Router because certain Node.js APIs are unavailable in the Workers environment. `unenv` offers compatible replacements for those APIs.
33
33
34
-
```sh
35
-
npm install unenv
36
-
```
34
+
<PackageManagerspkg="unenv"type="install" />
37
35
38
36
### Modify the `app.config.ts` file
39
37
40
38
To configure your application for Cloudflare Workers deployment, add the following lines to your `app.config.ts` file:
41
39
42
40
```ts
41
+
import { cloudflare } from'unenv'
42
+
43
43
server: {
44
44
preset: "cloudflare-module",
45
45
unenv: cloudflare,
@@ -48,7 +48,7 @@ To configure your application for Cloudflare Workers deployment, add the followi
48
48
49
49
This will set the correct build format and runtime environment for Cloudflare.
50
50
51
-
### Add a Wrnagler file
51
+
### Add a Wrangler file
52
52
53
53
Create a `wrangler.jsonc` or `wrangler.toml` file in the root of your project. This file is used to configure the Cloudflare Workers deployment.
54
54
@@ -74,9 +74,7 @@ Create a `wrangler.jsonc` or `wrangler.toml` file in the root of your project. T
74
74
75
75
You need to build your application before deploying it to Cloudflare Workers.
0 commit comments