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/router/installation/migrate-from-react-location.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,27 @@
2
2
title: Migration from React Location
3
3
---
4
4
5
-
Before you begin your journey in migrating from React Location, it's important that you have a good understanding of the [Routing Concepts](../../../routing/routing-concepts.md) and [Design Decisions](../../../decisions-on-dx.md) used by TanStack Router.
5
+
Before you begin your journey in migrating from React Location, it's important that you have a good understanding of the [Routing Concepts](../routing/routing-concepts.md) and [Design Decisions](../decisions-on-dx.md) used by TanStack Router.
6
6
7
7
## Differences between React Location and TanStack Router
8
8
9
9
React Location and TanStack Router share much of same design decisions concepts, but there are some key differences that you should be aware of.
10
10
11
11
- React Location uses _generics_ to infer types for routes, while TanStack Router uses _module declaration merging_ to infer types.
12
-
- Route configuration in React Location is done using a single array of route definitions, while in TanStack Router, route configuration is done using a tree of route definitions starting with the [root route](../../../routing/routing-concepts.md#the-root-route).
13
-
-[File-based routing](../../../routing/file-based-routing.md) is the recommended way to define routes in TanStack Router, while React Location only allows you to define routes in a single file using a code-based approach.
14
-
- TanStack Router does support a [code-based approach](../../../routing/code-based-routing.md) to defining routes, but it is not recommended for most use cases. You can read more about why, over here: [why is file-based routing the preferred way to define routes?](../../../decisions-on-dx.md#why-is-file-based-routing-the-preferred-way-to-define-routes)
12
+
- Route configuration in React Location is done using a single array of route definitions, while in TanStack Router, route configuration is done using a tree of route definitions starting with the [root route](../routing/routing-concepts.md#the-root-route).
13
+
-[File-based routing](../routing/file-based-routing.md) is the recommended way to define routes in TanStack Router, while React Location only allows you to define routes in a single file using a code-based approach.
14
+
- TanStack Router does support a [code-based approach](../routing/code-based-routing.md) to defining routes, but it is not recommended for most use cases. You can read more about why, over here: [why is file-based routing the preferred way to define routes?](../decisions-on-dx.md#why-is-file-based-routing-the-preferred-way-to-define-routes)
15
15
16
16
## Migration guide
17
17
18
18
In this guide we'll go over the process of migrating the [React Location Basic example](https://github.com/TanStack/router/tree/react-location/examples/basic) over to TanStack Router using file-based routing, with the end goal of having the same functionality as the original example (styling and other non-routing related code will be omitted).
19
19
20
20
> [!TIP]
21
-
> To use a code-based approach for defining your routes, you can read the [code-based Routing](../../../routing/code-based-routing.md) guide.
21
+
> To use a code-based approach for defining your routes, you can read the [code-based Routing](../routing/code-based-routing.md) guide.
22
22
23
23
### Step 1: Swap over to TanStack Router's dependencies
24
24
25
-
First, we need to install the dependencies for TanStack Router. For detailed installation instructions, see our [How to Install TanStack Router](../../../how-to/install.md) guide.
25
+
First, we need to install the dependencies for TanStack Router. For detailed installation instructions, see our [How to Install TanStack Router](../how-to/install.md) guide.
However, if your application does not use Vite, you use one of our other [supported bundlers](../../../routing/file-based-routing.md#getting-started-with-file-based-routing), or you can use the `@tanstack/router-cli` package to watch for changes in your routes files and automatically update the routes configuration.
60
+
However, if your application does not use Vite, you use one of our other [supported bundlers](../routing/file-based-routing.md#getting-started-with-file-based-routing), or you can use the `@tanstack/router-cli` package to watch for changes in your routes files and automatically update the routes configuration.
61
61
62
62
### Step 3: Add the file-based configuration file to your project
63
63
@@ -70,7 +70,7 @@ Create a `tsr.config.json` file in the root of your project with the following c
70
70
}
71
71
```
72
72
73
-
You can find the full list of options for the `tsr.config.json` file [here](../../../routing/file-based-routing.md).
73
+
You can find the full list of options for the `tsr.config.json` file in the [File-Based Routing](../routing/file-based-routing.md) guide.
74
74
75
75
### Step 4: Create the routes directory
76
76
@@ -249,19 +249,19 @@ You should now have successfully migrated your application from React Location t
249
249
250
250
React Location also has a few more features that you might be using in your application. Here are some guides to help you migrate those features:
Copy file name to clipboardExpand all lines: docs/router/installation/migrate-from-react-router.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
@@ -7,7 +7,7 @@ toc: false
7
7
8
8
Here is the [example repo](https://github.com/Benanna2019/SickFitsForEveryone/tree/migrate-to-tanstack/router/React-Router)
9
9
10
-
-[ ] Install Router - `npm i @tanstack/react-router` (see [detailed installation guide](../../../how-to/install.md))
10
+
-[ ] Install Router - `npm i @tanstack/react-router` (see [detailed installation guide](../how-to/install.md))
11
11
-[ ]**Optional:** Uninstall React Router to get TypeScript errors on imports.
12
12
- At this point I don’t know if you can do a gradual migration, but it seems likely you could have multiple router providers, not desirable.
13
13
- The api’s between React Router and TanStack Router are very similar and could most likely be handled in a sprint cycle or two if that is your companies way of doing things.
0 commit comments