Skip to content

Commit f260b2b

Browse files
committed
Update remix router readme
1 parent ab0da65 commit f260b2b

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

packages/router/README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# Router
1+
# Remix Router
22

3-
The `@remix-run/router` package is the heart of [React Router](https://github.com/remix-run/react-router) and provides all the core functionality for routing, data loading, data mutations, and navigation.
3+
The `@remix-run/router` package is a framework-agnostic routing package (sometimes referred to as a browser-emulator) that serves as the heart of [React Router][react-router] and [Remix][remix] and provides all the core functionality for routing coupled with data loading and data mutations. It comes with built-in handling of errors, race-conditions, interruptions, cancellations, lazy-loading data, and much, much more.
44

5-
If you're using React Router, you should never `import` anything directly from
6-
the `@remix-run/router` or `react-router` packages, but you should have everything
7-
you need in either `react-router-dom` or `react-router-native`. Both of those
8-
packages re-export everything from `@remix-run/router` and `react-router`.
5+
If you're using React Router, you should never `import` anything directly from the `@remix-run/router` or `react-router` packages, but you should have everything you need in either `react-router-dom` or `react-router-native`. Both of those packages re-export everything from `@remix-run/router` and `react-router`.
6+
7+
> **Warning**
8+
>
9+
> This router is a low-level package intended to be consumed by UI layer routing libraries. You should very likely not be using this package directly unless you are authoring a routing library such as [`react-router-dom`][react-router-repo] or one of it's other [UI ports][remix-routers-repo].
910
1011
## API
1112

@@ -15,38 +16,30 @@ A Router instance can be created using `createRouter`:
1516
// Create and initialize a router. "initialize" contains all side effects
1617
// including history listeners and kicking off the initial data fetch
1718
let router = createRouter({
18-
// Routes array using react-router RouteObject's
19-
routes,
19+
// Routes array
20+
routes: ,
2021
// History instance
2122
history,
22-
// Optional hydration data for SSR apps
23-
hydrationData?: HydrationState;
2423
}).initialize()
2524
```
2625

2726
Internally, the Router represents the state in an object of the following format, which is available through `router.state`. You can also register a subscriber of the signature `(state: RouterState) => void` to execute when the state updates via `router.subscribe()`;
2827

2928
```ts
3029
interface RouterState {
30+
// False during the initial data load, true once we have our initial data
31+
initialized: boolean;
3132
// The `history` action of the most recently completed navigation
3233
historyAction: Action;
3334
// The current location of the router. During a navigation this reflects
3435
// the "old" location and is updated upon completion of the navigation
3536
location: Location;
3637
// The current set of route matches
3738
matches: DataRouteMatch[];
38-
// False during the initial data load, true once we have our initial data
39-
initialized: boolean;
4039
// The state of the current navigation
4140
navigation: Navigation;
42-
// The state of an in-progress router.revalidate() calls
41+
// The state of any in-progress router.revalidate() calls
4342
revalidation: RevalidationState;
44-
// Scroll position to restore to for the active Location, false if we
45-
// should not restore,m or null if we don't have a saved position
46-
// Note: must be enabled via router.enableScrollRestoration()
47-
restoreScrollPosition: number | false | null;
48-
// Proxied `preventScrollReset` value passed to router.navigate() (default false)
49-
preventScrollReset: boolean;
5043
// Data from the loaders for the current matches
5144
loaderData: RouteData;
5245
// Data from the action for the current matches
@@ -55,6 +48,12 @@ interface RouterState {
5548
errors: RouteData | null;
5649
// Map of all active fetchers
5750
fetchers: Map<string, Fetcher>;
51+
// Scroll position to restore to for the active Location, false if we
52+
// should not restore, or null if we don't have a saved position
53+
// Note: must be enabled via router.enableScrollRestoration()
54+
restoreScrollPosition: number | false | null;
55+
// Proxied `preventScrollReset` value passed to router.navigate()
56+
preventScrollReset: boolean;
5857
}
5958
```
6059

@@ -101,3 +100,8 @@ router.fetch("key", "/page", {
101100
## Revalidation
102101

103102
By default, active loaders will revalidate after any navigation or fetcher mutation. If you need to kick off a revalidation for other use-cases, you can use `router.revalidate()` to re-execute all active loaders.
103+
104+
[react-router]: https://reactrouter.com
105+
[remix]: https://remix.run
106+
[react-router-repo]: https://github.com/remix-run/react-router
107+
[remix-routers-repo]: https://github.com/brophdawg11/remix-routers

0 commit comments

Comments
 (0)