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: docs/file-conventions/route-files-v2.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ new: true
5
5
6
6
# Route File Naming (v2)
7
7
8
-
You can opt-in to the new route file naming convention with a future flag in Remix config.
8
+
You can optin to the new route file naming convention with a future flag in Remix config.
9
9
10
10
```js filename=remix.config.js
11
11
/**@type{import('@remix-run/dev').AppConfig}*/
@@ -18,7 +18,7 @@ module.exports = {
18
18
19
19
While you can configure routes in [remix.config.js][remix-config], most routes are created with this file system convention. Add a file, get a route.
20
20
21
-
Please note that you can use either `.jsx` or `.tsx` file extensions. We'll stick with `.tsx` in the examples to avoid duplication.
21
+
Please note that you can use either `.js`, `.jsx`, `.ts` or `.tsx` file extensions. We'll stick with `.tsx` in the examples to avoid duplication.
22
22
23
23
## Root Route
24
24
@@ -29,7 +29,7 @@ app/
29
29
└── root.tsx
30
30
```
31
31
32
-
The file in `app/root.tsx` is your root layout, or "root route" (very sorry for those of you who pronounce those words the same way!). It works just like all other routes so you can export a [`loader`][loader], [`action`][action], etc.
32
+
The file in `app/root.tsx` is your root layout, or "root route" (very sorry for those of you who pronounce those words the same way!). It works just like all other routes, so you can export a [`loader`][loader], [`action`][action], etc.
33
33
34
34
The root route typically looks something like this. It serves as the root layout of the entire app, all other routes will render inside the `<Outlet />`.
35
35
@@ -84,7 +84,7 @@ Note that these routes will be rendered in the outlet of `app/root.tsx` because
84
84
Adding a `.` to a route filename will create a `/` in the URL.
85
85
86
86
<!-- prettier-ignore -->
87
-
```markdown lines=[4-6]
87
+
```markdown lines=[5-7]
88
88
app/
89
89
├── routes/
90
90
│ ├── _index.tsx
@@ -166,7 +166,7 @@ app/
166
166
└── root.tsx
167
167
```
168
168
169
-
All of the routes that start with `concerts.` will be child routes of `concerts.tsx` and render inside the parent route's [outlet][outlet].
169
+
All the routes that start with `concerts.` will be child routes of `concerts.tsx` and render inside the parent route's [outlet][outlet].
@@ -180,7 +180,7 @@ Note you typically want to add an index route when you add nested routes so that
180
180
181
181
## Nested URLs without Layout Nesting
182
182
183
-
Sometimes you want the URL to be nested but you don't want the automatic layout nesting. You can opt-out of nesting with a trailing underscore on the parent segment:
183
+
Sometimes you want the URL to be nested, but you don't want the automatic layout nesting. You can optout of nesting with a trailing underscore on the parent segment:
184
184
185
185
<!-- prettier-ignore -->
186
186
```markdown lines=[8]
@@ -260,7 +260,7 @@ app/
260
260
261
261
## Splat Routes
262
262
263
-
While [dynamic segments][dynamic-segments] match a single path segment (the stuff between two `/` in a url), a splat route will match the rest of a URL, including the slashes.
263
+
While [dynamic segments][dynamic-segments] match a single path segment (the stuff between two `/` in a URL), a splat route will match the rest of a URL, including the slashes.
Copy file name to clipboardExpand all lines: docs/file-conventions/routes-files.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ title: Route File Naming
8
8
9
9
Setting up routes in Remix is as simple as creating files in your `app` directory. These are the conventions you should know to understand how routing in Remix works.
10
10
11
-
Please note that you can use either `.js`, `.jsx`or `.tsx` file extensions depending on whether or not you use TypeScript. We'll stick with `.tsx` in the examples to avoid duplication.
11
+
Please note that you can use either `.js`, `.jsx`, `.ts`or `.tsx` file extensions. We'll stick with `.tsx` in the examples to avoid duplication.
12
12
13
13
## Root Route
14
14
@@ -167,7 +167,7 @@ app/
167
167
168
168
</details>
169
169
170
-
In the example above, the `blog.tsx` is a "layout route" for everything within the `blog` directory (`blog/index.tsx` and `blog/categories.tsx`). When a route has the same name as its directory (`routes/blog.tsx` and `routes/blog/`), it becomes a layout route for all of the routes inside that directory ("child routes"). Similar to your [root route][root-route], the parent route should render an `<Outlet />` where the child routes should appear. This is how you can create multiple levels of persistent layout nesting associated with URLs.
170
+
In the example above, the `blog.tsx` is a "layout route" for everything within the `blog` directory (`blog/index.tsx` and `blog/categories.tsx`). When a route has the same name as its directory (`routes/blog.tsx` and `routes/blog/`), it becomes a layout route for all the routes inside that directory ("child routes"). Similar to your [root route][root-route], the parent route should render an `<Outlet />` where the child routes should appear. This is how you can create multiple levels of persistent layout nesting associated with URLs.
Copy file name to clipboardExpand all lines: docs/guides/constraints.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ The server needs everything in this file but the browser only needs the componen
43
43
44
44
To remove the server code from the browser bundles, the Remix compiler creates a proxy module in front of your route and bundles that instead. The proxy for this route would look like:
Copy file name to clipboardExpand all lines: docs/guides/data-loading.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ export default function Products() {
45
45
}
46
46
```
47
47
48
-
The component renders on the server and in the browser. The loader _only runs on the server_. That means our hard-coded products array doesn't get included in the browser bundles and it's safe to use server-only for APIs and SDKs for things like database, payment processing, content management systems, etc.
48
+
The component renders on the server and in the browser. The loader _only runs on the server_. That means our hard-coded products array doesn't get included in the browser bundles, and it's safe to use server-only for APIs and SDKs for things like database, payment processing, content management systems, etc.
49
49
50
50
If your server-side modules end up in client bundles, move the imports for those modules to a file named `{something}.server.ts` with the `.server.ts` suffix to ensure they are excluded.
51
51
@@ -107,9 +107,9 @@ While you may be uncomfortable throwing errors like this with `invariant` when i
107
107
108
108
## External APIs
109
109
110
-
Remix polyfills the `fetch` API on your server so it's very easy to fetch data from existing JSON APIs. Instead of managing state, errors, race conditions, and more yourself, you can do the fetch from your loader (on the server) and let Remix handle the rest.
110
+
Remix polyfills the `fetch` API on your server, so it's very easy to fetch data from existing JSON APIs. Instead of managing state, errors, race conditions, and more yourself, you can do the fetch from your loader (on the server) and let Remix handle the rest.
111
111
112
-
```tsx filename=app/routes/gists.jsx lines=[5]
112
+
```tsx filename=app/routes/gists.tsx lines=[5]
113
113
import { json } from"@remix-run/node"; // or cloudflare/deno
114
114
import { useLoaderData } from"@remix-run/react";
115
115
@@ -314,7 +314,7 @@ Given the following URLs, the search params would be parsed as follows:
314
314
315
315
### Data Reloads
316
316
317
-
When multiple nested routes are rendering and the search params change, all of the routes will be reloaded (instead of just the new or changed routes). This is because search params are a cross-cutting concern and could affect any loader. If you would like to prevent some of your routes from reloading in this scenario, use [shouldRevalidate][should-revalidate].
317
+
When multiple nested routes are rendering and the search params change, all the routes will be reloaded (instead of just the new or changed routes). This is because search params are a cross-cutting concern and could affect any loader. If you would like to prevent some of your routes from reloading in this scenario, use [shouldRevalidate][should-revalidate].
318
318
319
319
### Search Params in Components
320
320
@@ -471,7 +471,7 @@ export default function ProductFilters() {
471
471
472
472
Often you want to keep some inputs, like checkboxes, in sync with the search params in the URL. This can get a little tricky with React's controlled component concept.
473
473
474
-
This is only needed if the search params can be set in two ways and we want the inputs to stay in sync with the search params. For example, both the `<input type="checkbox">` and the `Link` can change the brand in this component:
474
+
This is only needed if the search params can be set in two ways, and we want the inputs to stay in sync with the search params. For example, both the `<input type="checkbox">` and the `Link` can change the brand in this component:
@@ -514,7 +514,7 @@ If the user clicks the checkbox and submits the form, the URL updates and the ch
514
514
515
515
Now we have the opposite problem: clicking the link updates both the URL and the checkbox state but _the checkbox no longer works_ because React prevents the state from changing until the URL that controls it changes--and it never will because we can't change the checkbox and resubmit the form.
516
516
517
-
React wants you to control it with some state but we want the user to control it until they submit the form, and then we want the URL to control it when it changes. So we're in this "sorta-controlled" spot.
517
+
React wants you to control it with some state, but we want the user to control it until they submit the form, and then we want the URL to control it when it changes. So we're in this "sorta-controlled" spot.
518
518
519
519
You have two choices, and what you pick depends on the user experience you want.
520
520
@@ -657,9 +657,9 @@ function SearchCheckbox({ name, value }) {
657
657
658
658
Remix optimizes the user experiences by only loading the data for the parts of the page that are changing on navigation. For example, consider the UI you're using right now in these docs. The navbar on the side is in a parent route that fetched the dynamically-generated menu of all the docs, and the child route fetched the document you're reading right now. If you click a link in the sidebar, Remix knows that the parent route will remain on the page - but the child route's data will change because the url param for the document will change. With this insight, Remix _will not refetch the parent route's data_.
659
659
660
-
Without Remix the next question is "how do I reload all of the data?". This is built into Remix as well. Whenever an [action][action] is called (the user submitted a form or you, the programmer, called `submit` from `useSubmit`), Remix will automatically reload all of the routes on the page to capture any changes that might have happened.
660
+
Without Remix the next question is "how do I reload all the data?". This is built into Remix as well. Whenever an [action][action] is called (the user submitted a form or you, the programmer, called `submit` from `useSubmit`), Remix will automatically reload all the routes on the page to capture any changes that might have happened.
661
661
662
-
You don't have to worry about expiring caches or avoid overfetching data as the user interacts with your app, it's all automatic.
662
+
You don't have to worry about expiring caches or avoid over-fetching data as the user interacts with your app, it's all automatic.
663
663
664
664
There are three cases where Remix will reload all of your routes:
665
665
@@ -671,7 +671,7 @@ All of these behaviors emulate the browser's default behavior. In these cases, R
671
671
672
672
## Data Libraries
673
673
674
-
Thanks to Remix's data conventions and nested routes, you'll usually find you don't need to reach for client side data libraries like React Query, SWR, Apollo, Relay, urql and others. If you're using global state management libraries like redux, primarily for interacting with data on the server, it's also unlikely you'll need those.
674
+
Thanks to Remix's data conventions and nested routes, you'll usually find you don't need to reach for client side data libraries like React Query, SWR, Apollo, Relay, `urql` and others. If you're using global state management libraries like redux, primarily for interacting with data on the server, it's also unlikely you'll need those.
675
675
676
676
Of course, Remix doesn't prevent you from using them (unless they require bundler integration). You can bring whatever React data libraries you like and use them wherever you think they'll serve your UI better than the Remix APIs. In some cases you can use Remix for the initial server render and then switch over to your favorite library for the interactions afterward.
Copy file name to clipboardExpand all lines: docs/guides/mdx.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,9 +126,7 @@ import Component, {
126
126
127
127
The following example demonstrates how you might build a simple blog with MDX, including individual pages for the posts themselves and an index page that shows all posts.
128
128
129
-
In `app/routes/index.jsx`:
130
-
131
-
```tsx
129
+
```tsx filename=app/routes/index.tsx
132
130
import { json } from"@remix-run/node"; // or cloudflare/deno
0 commit comments