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
`react-router.config.ts` is your [React Router config file](https://reactrouter.com/explanation/special-files#react-routerconfigts).
61
-
In this file:
62
-
-`ssr` is set to `true`, meaning that your application will use server-side rendering.
63
-
-`future.unstable_viteEnvironmentApi` is set to `true` to enable compatibility with the [Cloudflare Vite plugin](/workers/vite-plugin/).
64
-
65
-
:::note
66
-
SPA mode and prerendering are not currently supported when using the [Cloudflare Vite plugin](/workers/vite-plugin/).
67
-
If you wish to use React Router in an SPA then we recommend starting with the [React template](/workers/frameworks/framework-guides/react/) and using React Router [as a library](https://reactrouter.com/start/data/installation).
68
-
:::
69
-
70
-
`vite.config.ts` is your [Vite config file](https://vite.dev/config/).
71
-
The React Router and Cloudflare plugins are included in the `plugins` array.
72
-
The [Cloudflare Vite plugin](/workers/vite-plugin/) runs your server code in the Workers runtime, ensuring your local development environment is as close to production as possible.
73
-
74
-
`wrangler.jsonc` is your [Worker config file](/workers/wrangler/configuration/).
75
-
In this file:
76
-
- `main` points to `./workers/app.ts`.
77
-
This is the entry file for your Worker.
78
-
The default export includes a [`fetch` handler](/workers/runtime-apis/fetch/), which delegates the request to React Router.
79
-
- If you want to add [bindings](/workers/runtime-apis/bindings/) to resources on Cloudflare's developer platform, you configure them here.
80
-
</Details>
43
+
/>
44
+
45
+
<Detailsheader="How is this project set up?">
46
+
47
+
Below is a simplified file tree of the project.
48
+
49
+
<FileTree>
50
+
- my-react-router-app
51
+
- app
52
+
- routes
53
+
- ...
54
+
- entry.server.ts
55
+
- root.tsx
56
+
- routes.ts
57
+
- workers
58
+
- app.ts
59
+
- react-router.config.ts
60
+
- vite.config.ts
61
+
- wrangler.jsonc
62
+
</FileTree>
63
+
64
+
`react-router.config.ts` is your [React Router config file](https://reactrouter.com/explanation/special-files#react-routerconfigts).
65
+
In this file:
66
+
- `ssr` is set to `true`, meaning that your application will use server-side rendering.
67
+
- `future.unstable_viteEnvironmentApi` is set to `true` to enable compatibility with the [Cloudflare Vite plugin](/workers/vite-plugin/).
68
+
69
+
:::note
70
+
SPA mode and prerendering are not currently supported when using the [Cloudflare Vite plugin](/workers/vite-plugin/).
71
+
If you wish to use React Router in an SPA then we recommend starting with the [React template](/workers/frameworks/framework-guides/react/) and using React Router [as a library](https://reactrouter.com/start/data/installation).
72
+
:::
73
+
74
+
`vite.config.ts` is your [Vite config file](https://vite.dev/config/).
75
+
The React Router and Cloudflare plugins are included in the `plugins` array.
76
+
The [Cloudflare Vite plugin](/workers/vite-plugin/) runs your server code in the Workers runtime, ensuring your local development environment is as close to production as possible.
77
+
78
+
`wrangler.jsonc` is your [Worker config file](/workers/wrangler/configuration/).
79
+
In this file:
80
+
- `main` points to `./workers/app.ts`.
81
+
This is the entry file for your Worker.
82
+
The default export includes a [`fetch` handler](/workers/runtime-apis/fetch/), which delegates the request to React Router.
83
+
- If you want to add [bindings](/workers/runtime-apis/bindings/) to resources on Cloudflare's developer platform, you configure them here.
84
+
85
+
</Details>
81
86
82
87
2.**Develop locally**
83
88
84
89
After creating your project, run the following command in your project directory to start a local development server.
90
+
85
91
<PackageManagerstype="run"args="dev" />
86
-
<Detailsheader="What's happening in local development?">
87
-
This project uses React Router in combination with the [Cloudflare Vite plugin](/workers/vite-plugin/).
88
-
This means that your application runs in the Cloudflare Workers runtime, just like in production, and enables access to local emulations of bindings.
89
-
</Details>
92
+
93
+
<Detailsheader="What's happening in local development?">
94
+
This project uses React Router in combination with the [Cloudflare Vite plugin](/workers/vite-plugin/).
95
+
This means that your application runs in the Cloudflare Workers runtime, just like in production, and enables access to local emulations of bindings.
96
+
</Details>
90
97
91
98
3.**Deploy your project**
92
99
93
-
Your project can be deployed to a `*.workers.dev` subdomain or a [Custom Domain](/workers/configuration/routing/custom-domains/) from your own machine or from any CI/CD system, including Cloudflare's own [Workers Builds](/workers/ci-cd/builds/).
100
+
Your project can be deployed to a `*.workers.dev` subdomain or a [Custom Domain](/workers/configuration/routing/custom-domains/) from your own machine or from any CI/CD system, including Cloudflare's own [Workers Builds](/workers/ci-cd/builds/).
94
101
95
-
The following command will build and deploy your project. If you are using CI, ensure you update your ["deploy command"](/workers/ci-cd/builds/configuration/#build-settings) configuration appropriately.
102
+
The following command will build and deploy your project. If you are using CI, ensure you update your ["deploy command"](/workers/ci-cd/builds/configuration/#build-settings) configuration appropriately.
96
103
97
-
<PackageManagerstype="run"args={"deploy"} />
104
+
<PackageManagerstype="run"args={"deploy"} />
98
105
99
106
</Steps>
100
107
101
108
## Use bindings with React Router
102
109
103
110
With bindings, your application can be fully integrated with the Cloudflare Developer Platform, giving you access to compute, storage, AI and more.
104
-
As you have direct access to your Worker entry file (`workers/app.ts`), you can also add additional exports such as [Durable Objects](/durable-objects/) and [Workflows](/workflows/).
111
+
112
+
Once you have configured the bindings in the Wrangler configuration file, they are then available within `context.cloudflare` in your loader or action functions:
As you have direct access to your Worker entry file (`workers/app.ts`), you can also add additional exports such as [Durable Objects](/durable-objects/) and [Workflows](/workflows/)
125
+
126
+
<Detailsheader="Example: Using Workflows">
127
+
128
+
Here is an example of how to set up a simple Workflow in your Worker entry file.
0 commit comments