createMemoryRouter
On this page

createMemoryRouter

Summary

Reference Documentation ↗

Create a new DataRouter that manages the application path using an in-memory History stack. Useful for non-browser environments without a DOM API.

Signature

function createMemoryRouter(
  routes: RouteObject[],
  opts?: MemoryRouterOpts,
): DataRouter

Params

routes

Application routes

opts.basename

Basename path for the application.

opts.dataStrategy

Override the default data strategy of loading in parallel. Only intended for advanced usage.

opts.future

Future flags to enable for the router.

opts.unstable_getContext

Function to provide the initial context values for all client side navigations/fetches

opts.hydrationData

Hydration data to initialize the router with if you have already performed data loading on the server.

opts.initialEntries

Initial entries in the in-memory history stack

opts.initialIndex

Index of initialEntries the application should initialize to

opts.patchRoutesOnNavigation

Lazily define portions of the route tree on navigations.

Returns

An initialized DataRouter to pass to <RouterProvider>

Docs and examples CC 4.0
Edit