Skip to content

Commit 668c826

Browse files
Remove Remix pages guide (#25263)
1 parent 7802744 commit 668c826

File tree

1 file changed

+3
-175
lines changed

1 file changed

+3
-175
lines changed

src/content/docs/pages/framework-guides/deploy-a-remix-site.mdx

Lines changed: 3 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -11,180 +11,8 @@ import {
1111
WranglerConfig,
1212
} from "~/components";
1313

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.
1515

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).
1717

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:
23-
24-
<PackageManagers
25-
type="create"
26-
pkg="cloudflare@latest"
27-
args="my-remix-app --framework=remix --platform=pages"
28-
/>
29-
30-
`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:
40-
41-
```sh
42-
# choose Cloudflare Pages
43-
cd my-remix-app
44-
npm run dev
45-
```
46-
47-
<Render file="tutorials-before-you-start" product="pages" />
48-
49-
<Render
50-
file="framework-guides/create-github-repository_no_init"
51-
product="pages"
52-
/>
53-
54-
## Deploy with Cloudflare Pages
55-
56-
<Render file="deploy-via-c3" product="pages" params={{ name: "Remix" }} />
57-
58-
### Deploy via the Cloudflare dashboard
59-
60-
<Render
61-
file="framework-guides/learn-more"
62-
product="pages"
63-
params={{ name: "Remix" }}
64-
/>
65-
66-
<PagesBuildPreset framework="remix" />
67-
68-
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:
99-
100-
```typescript
101-
export const loader = ({ context }: LoaderFunctionArgs) => {
102-
const { env, cf, ctx } = context.cloudflare;
103-
env.MY_BINDING; // Access bound resources here
104-
// ... more loader code here...
105-
};
106-
```
107-
108-
:::note[Correcting the env type]
109-
110-
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:
158-
159-
```typescript
160-
import type { LoaderFunction } from "@remix-run/cloudflare";
161-
import { json } from "@remix-run/cloudflare";
162-
import { useLoaderData } from "@remix-run/react";
163-
164-
export const loader: LoaderFunction = async ({ context, params }) => {
165-
const { env, cf, ctx } = context.cloudflare;
166-
let { results } = await env.DB.prepare(
167-
"SELECT * FROM products where id = ?1"
168-
).bind(params.productId).run();
169-
return json(results);
170-
};
171-
172-
export default function Index() {
173-
const results = useLoaderData<typeof loader>();
174-
return (
175-
<div>
176-
<h1>Welcome to Remix</h1>
177-
<div>
178-
A value from D1:
179-
<pre>{JSON.stringify(results)}</pre>
180-
</div>
181-
</div>
182-
);
183-
}
184-
```
185-
186-
<Render
187-
file="framework-guides/learn-more"
188-
product="pages"
189-
params={{ one: "Remix" }}
190-
/>
18+
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

Comments
 (0)