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
Copy file name to clipboardExpand all lines: src/content/docs/pages/framework-guides/deploy-a-remix-site.mdx
+3-175Lines changed: 3 additions & 175 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,180 +11,8 @@ import {
11
11
WranglerConfig,
12
12
} from"~/components";
13
13
14
-
[Remix](https://remix.run/) is a framework that is focused on fully utilizing the power of the web. Like Cloudflare Workers, it uses modern JavaScript APIs, and it places emphasis on web fundamentals such as meaningful HTTP status codes, caching and optimizing for both usability and performance.
14
+
[Remix](https://remix.run/) is a framework that focused on web standard. The framework is no longer recommended for new projects by the authors and its successor React Router should be used instead.
15
15
16
-
In this guide, you will create a new Remix application and deploy to Cloudflare Pages.
16
+
To start a new React Router project please refer to the [React Router Workers guide](/workers/framework-guides/web-apps/react-router).
17
17
18
-
## Setting up a new project
19
-
20
-
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 Remix's official setup tool, and provide the option to deploy instantly.
21
-
22
-
To use `create-cloudflare` to create a new Remix project, run the following command:
`create-cloudflare` will install additional dependencies, including the [Wrangler](/workers/wrangler/install-and-update/#check-your-wrangler-version) CLI and any necessary adapters, and ask you setup questions.
31
-
32
-
:::caution[Before you deploy]
33
-
34
-
Your Remix project will include a `functions/[[path]].ts` file. The `[[path]]` filename indicates that this file will handle requests to all incoming URLs. Refer to [Path segments](/pages/functions/routing/#dynamic-routes) to learn more.
35
-
36
-
The `functions/[[path]].ts` will not function as expected if you attempt to deploy your site before running `remix vite:build`.
37
-
:::
38
-
39
-
After setting up your project, change the directory and render your project by running the following command:
After configuring your site, you can begin your first deploy. You should see Cloudflare Pages installing `npm`, your project dependencies, and building your site before deploying it.
69
-
70
-
:::note
71
-
72
-
For the complete guide to deploying your first site to Cloudflare Pages, refer to the [Get started guide](/pages/get-started/).
73
-
74
-
:::
75
-
76
-
After deploying your site, you will receive a unique subdomain for your project on `*.pages.dev`.
77
-
Every time you commit new code to your Remix site, Cloudflare Pages will automatically rebuild your project and deploy it. You will also get access to [preview deployments](/pages/configuration/preview-deployments/) on new pull requests, so you can preview how changes look to your site before deploying them to production.
78
-
79
-
### Deploy via the Wrangler CLI
80
-
81
-
If you use [`create-cloudflare`(C3)](https://www.npmjs.com/package/create-cloudflare) to create your new Remix project, C3 will automatically scaffold your project with [`wrangler`](/workers/wrangler/). To deploy your project, run the following command:
82
-
83
-
```sh
84
-
npm run deploy
85
-
```
86
-
87
-
## Create and add a binding to your Remix application
88
-
89
-
To add a binding to your Remix application, refer to [Bindings](/pages/functions/bindings/).
90
-
A [binding](/pages/functions/bindings/) allows your application to interact with Cloudflare developer products, such as [KV namespaces](/kv/concepts/how-kv-works/), [Durable Objects](/durable-objects/), [R2 storage buckets](/r2/), and [D1 databases](/d1/).
91
-
92
-
### Binding resources in local development
93
-
94
-
Remix uses Wrangler's [`getPlatformProxy`](/workers/wrangler/api/#getplatformproxy) to simulate the Cloudflare environment locally. You configure `getPlatformProxy` in your project's `vite.config.ts` file via [`cloudflareDevProxyVitePlugin`](https://remix.run/docs/en/main/future/vite#cloudflare-proxy).
95
-
96
-
To bind resources in local development, you need to configure the bindings in the Wrangler file. Refer to [Bindings](/workers/wrangler/configuration/#bindings) to learn more.
97
-
98
-
Once you have configured the bindings in the Wrangler file, the proxies are then available within `context.cloudflare` in your `loader` or `action` functions:
You may have noticed that `context.cloudflare.env` is not typed correctly when you add additional bindings in the [Wrangler configuration file](/workers/wrangler/configuration/).
111
-
112
-
To fix this, run `npm run typegen` to generate the missing types. This will update the `Env` interface defined in `worker-configuration.d.ts`.
113
-
After running the command, you can access the bindings in your `loader` or `action` using `context.cloudflare.env` as shown above.
114
-
:::
115
-
116
-
### Binding resources in production
117
-
118
-
To bind resources in production, you need to configure the bindings in the Cloudflare dashboard. Refer to the [Bindings](/pages/functions/bindings/) documentation to learn more.
119
-
120
-
Once you have configured the bindings in the Cloudflare dashboard, the proxies are then available within `context.cloudflare.env` in your `loader` or `action` functions as shown [above](#binding-resources-in-local-development).
121
-
122
-
## Example: Access your D1 database in a Remix application
123
-
124
-
As an example, you will bind and query a D1 database in a Remix application.
125
-
126
-
1. Create a D1 database. Refer to the [D1 documentation](/d1/) to learn more.
127
-
2. Configure bindings for your D1 database in the Wrangler file:
128
-
129
-
<WranglerConfig>
130
-
131
-
```toml
132
-
[[ d1_databases ]]
133
-
binding = "DB"
134
-
database_name = "<YOUR_DATABASE_NAME>"
135
-
database_id = "<YOUR_DATABASE_ID>"
136
-
```
137
-
138
-
</WranglerConfig>
139
-
140
-
3. Run `npm run typegen` to generate TypeScript types for your bindings.
141
-
142
-
```sh
143
-
npm run typegen
144
-
```
145
-
146
-
```sh output
147
-
> typegen
148
-
> wrangler types
149
-
150
-
⛅️ wrangler 3.48.0
151
-
-------------------
152
-
interface Env {
153
-
DB: D1Database;
154
-
}
155
-
```
156
-
157
-
4. Access the D1 database in your `loader` function:
And if you have an existing Remix application consider migrating it to React Router as described in the [official Remix upgrade documentation](https://reactrouter.com/upgrading/remix).
0 commit comments