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/Admin.md
+29-2Lines changed: 29 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,6 +159,7 @@ Here are all the props accepted by the component:
159
159
|`queryClient`| Optional |`QueryClient`| - | The react-query client |
160
160
|`ready`| Optional |`Component`|`Ready`| The content of the ready page |
161
161
|`requireAuth`| Optional |`boolean`|`false`| Flag to require authentication for all routes |
162
+
|`routerProvider`| Optional |`RouterProvider`|`reactRouterProvider`| The router provider for navigation |
162
163
|`store`| Optional |`Store`| - | The Store for managing user preferences |
163
164
|`theme`| Optional |`object`|`default LightTheme`| The main (light) theme configuration |
164
165
|`title`| Optional |`string`| - | The error page title |
@@ -1050,6 +1051,28 @@ const App = () => (
1050
1051
);
1051
1052
```
1052
1053
1054
+
## `routerProvider`
1055
+
1056
+
React-admin uses a router abstraction layer that allows you to choose between different routing libraries. By default, it uses [react-router](https://reactrouter.com/), but you can also use [TanStack Router](./TanStackRouter.md).
1057
+
1058
+
To use TanStack Router, pass the `tanStackRouterProvider` to the `routerProvider` prop:
1059
+
1060
+
```tsx
1061
+
import { Admin, Resource } from 'react-admin';
1062
+
import { tanStackRouterProvider } from 'ra-router-tanstack';
See the [TanStack Router documentation](./TanStackRouter.md) for more details on using TanStack Router with react-admin.
1073
+
1074
+
**Tip**: When using `tanStackRouterProvider`, navigation blocking (used by `warnWhenUnsavedChanges`) works out of the box, without requiring a Data Router setup.
1075
+
1053
1076
## `store`
1054
1077
1055
1078
The `<Admin>` component initializes a [Store](./Store.md) for user preferences using `localStorage` as the storage engine. You can override this by passing a custom `store` prop.
@@ -1156,9 +1179,13 @@ const App = () => (
1156
1179
exportdefaultApp;
1157
1180
```
1158
1181
1159
-
## Using A Custom Router
1182
+
## Using A Different Router Library
1183
+
1184
+
React-admin supports multiple routing libraries through its [router abstraction](./Routing.md). By default, it uses react-router, but you can also use [TanStack Router](./TanStackRouter.md) via the [`routerProvider`](#routerprovider) prop.
1185
+
1186
+
## Using A Custom react-router Configuration
1160
1187
1161
-
React-admin uses [the react-router library](https://reactrouter.com/) to handle routing, with a [HashRouter](https://reactrouter.com/en/6/router-components/hash-router#hashrouter). This means that the hash portion of the URL (i.e. `#/posts/123` in the example) contains the main application route. This strategy has the benefit of working without a server, and with legacy web browsers.
1188
+
By default, react-admin uses react-router with a [HashRouter](https://reactrouter.com/en/6/router-components/hash-router#hashrouter). This means that the hash portion of the URL (i.e. `#/posts/123` in the example) contains the main application route. This strategy has the benefit of working without a server, and with legacy web browsers.
1162
1189
1163
1190
But you may want to use another routing strategy, e.g. to allow server-side rendering of individual pages. React-router offers various Router components to implement such routing strategies. If you want to use a different router, simply put your app in a create router function. React-admin will detect that it's already inside a router, and skip its own router.
If you omit `<TitlePortal>`, `<AppBar>` will no longer display the page title. This can be done on purpose, e.g. if you want to render something completely different in the AppBar, like a company logo and a search engine:
Pass an `sx` prop to customize the style of the main component and the underlying elements (see [the `sx` documentation](./SX.md) for syntax and examples).
@@ -194,7 +198,7 @@ By default, the `<AppBar>` renders three buttons in addition to the user menu:
194
198
195
199
If you want to reorder or remove these buttons, you can customize the toolbar by passing a `toolbar` prop.
196
200
197
-
```jsx
201
+
```jsx
198
202
// in src/MyAppBar.js
199
203
import {
200
204
AppBar,
@@ -246,17 +250,15 @@ If your app uses [authentication](./Authentication.md), the `<AppBar>` component
246
250
Your browser does not support the video tag.
247
251
</video>
248
252
249
-
250
-
The content of the user menu depends on the return value of `authProvider.getIdentity()`. The user menu icon renders an anonymous avatar, or the `avatar` property of the identity object if present. If the identity object contains a `fullName` property, it is displayed after the avatar.
253
+
The content of the user menu depends on the return value of `authProvider.getIdentity()`. The user menu icon renders an anonymous avatar, or the `avatar` property of the identity object if present. If the identity object contains a `fullName` property, it is displayed after the avatar.
251
254
252
255
You can customize the user menu by passing a `userMenu` prop to the `<AppBar>` component.
Copy file name to clipboardExpand all lines: docs/Architecture.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
@@ -15,7 +15,7 @@ React-admin is specifically designed to build [Single-Page Applications (SPA)](h
15
15
16
16
The SPA architecture ensures that react-admin apps are [exceptionally fast](./Features.md#fast), easy to host, and compatible with existing APIs without requiring a dedicated backend.
17
17
18
-
To achieve this, react-admin utilizes an internal router, powered by `react-router`, to display the appropriate screen when the user clicks on a link. Developers can define routes using the [`<Resource>`](./Resource.md) component for CRUD routes and the [`<CustomRoutes>`](./CustomRoutes.md) component for other routes.
18
+
To achieve this, react-admin utilizes an internal routerto display the appropriate screen when the user clicks on a link. By default, this router is powered by [react-router](https://reactrouter.com/), but you can also use [TanStack Router](./TanStackRouter.md) through the `routerProvider` prop. Developers can define routes using the [`<Resource>`](./Resource.md) component for CRUD routes and the [`<CustomRoutes>`](./CustomRoutes.md) component for other routes.
19
19
20
20
For example, the following react-admin application:
Note over RA:handleCallback()<br/>Auth0Client.handleRedirectCallback()
446
445
RA->>U: Redirects to /posts
447
446
```
448
-
Edited with https://mermaid.live/edit
447
+
448
+
Edited with <https://mermaid.live/edit>
449
449
{% endcomment %}
450
450
451
451
**Tip:** You can choose when to redirect users to the third-party authentication service, such as directly in the `AuthProvider.checkAuth()` method or when they click a button on a [custom login page](#customizing-the-login-component).
0 commit comments