Skip to content

Commit

Permalink
Add relative routing example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Apr 14, 2023
1 parent bf8d169 commit 9f164a6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ A Router instance can be created using `createRouter`:
// including history listeners and kicking off the initial data fetch
let router = createRouter({
// Required properties
routes, // Routes array
history, // History instance
routes: [{
path: '/',
loader: ({ request, params }) => { /* ... */ },
children: [{
path: 'home',
loader: ({ request, params }) => { /* ... */ },
}]
},
history: createBrowserHistory(),

// Optional properties
basename, // Base path
mapRouteProperties, // Map function framework-agnostic routes to framework-aware routes
mapRouteProperties, // Map framework-agnostic routes to framework-aware routes
future, // Future flags
hydrationData, // Hydration data if using server-side-rendering
}).initialize();
Expand Down Expand Up @@ -83,6 +90,11 @@ router.navigate("/page", {
formMethod: "post",
formData,
});

// Relative routing from a source routeId
router.navigate("../../somewhere", {
fromRouteId: "active-route-id",
});
```

### Fetchers
Expand Down

0 comments on commit 9f164a6

Please sign in to comment.