{"name":"@remix-run/router","version":"0.0.0-experimental-b162e81d","keywords":["remix","router","location"],"author":{"name":"Remix Software","email":"hello@remix.run"},"license":"MIT","_id":"@remix-run/router@0.0.0-experimental-b162e81d","maintainers":[{"name":"chancestrickland","email":"hi@chance.dev"},{"name":"mjackson","email":"npm@mjackson.me"}],"homepage":"https://github.com/remix-run/react-router#readme","bugs":{"url":"https://github.com/remix-run/react-router/issues"},"dist":{"shasum":"e4c8a711c92e1d9353ee3294d5fccbabe18d4acc","tarball":"http://registry-npm.ywwl.com/@remix-run/router/download/@remix-run/router-0.0.0-experimental-b162e81d.tgz","fileCount":20,"integrity":"sha512-ksLow+3FUMRACWDY2XjQ/oAEq+5ERZYddFoSOg7GEllyrwYRmogoIbFK0WHRt+qYLbcIBRaI/jwDG0lhAHjkGw==","signatures":[{"sig":"MEQCIBiw0VUmWhvujHo/LJ+U/yGJ4sIWBt1QLPvsPu01gi7UAiBX+fUQp1sFkm76tiyIEb9uwlzXv6l26xt0EDqx2Anomg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1955161,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkFJxIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpv/w//WuzhUIz+J6JlNzpAYV/YD58U1vK5SPlWAhTeImnry/dkHTtv\r\ngPseu0drPAEVty2iK0bZD04ufj4WgHB13lDQBZI21U7IPUgVeFAFd4+vprjt\r\nfvWbSARgMw0CYeYxs8iZeas43bWlSENJj5A9/TGWA1IlmrEclT3K/wfUFKB6\r\nU4grOwDZQQIDkl9UUD6nnIjNqwjaX1oPRL4Y3T2rSx7suILGcVAgxDcjt4EV\r\n+59ACcQXhvnmgUwKfj6nAnfDjSEPAkD6UU4d6uyd/cNiDIBcI5XGo2VnFGmw\r\nli2AJZc4kjMPWcksawwss0A/vJwKUywRjqIdBud5IyJbN3gj66NeklZKY+p4\r\nLIdvEaMj76yBS/XG3L5VVvalMEoOTFV4XQ6QQ2M3c/frdyznAWHibRk9UOyE\r\ndIq2mhyurlEvNNLLMsfwnCYnq+NPaVL+eF60pKLudLOTwQp12NXTQaOSkBMj\r\nH0jBht+zzlU32uvV2EUgC3dq62MEh4JbCqjKnAUcOVu6sca2jHGU0l+fOg7W\r\nTk8e2/lfgFh34zVv0RKJjKRn2ac3vcF10H21Hkgxxu1+Rq5qQoeCnQriWSX9\r\nRLY65GIYYUyceF2fZW+Jg6wCdqw96FVu4ESXA0kSzhzYYs6rmfN+d/pkdbMH\r\nezG+ELoBvLjJD0m9X1UEgo1jAQYjXa5j0N8=\r\n=3Txl\r\n-----END PGP SIGNATURE-----\r\n","size":514500,"noattachment":false,"key":"/@remix-run/router/-/@remix-run/router-0.0.0-experimental-b162e81d.tgz"},"main":"./dist/router.cjs.js","types":"./dist/index.d.ts","unpkg":"./dist/router.umd.min.js","module":"./dist/router.js","readme":"# Remix Router\n\nThe `@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.\n\nIf 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`.\n\n> **Warning**\n>\n> 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].\n\n## API\n\nA Router instance can be created using `createRouter`:\n\n```js\n// Create and initialize a router.  \"initialize\" contains all side effects\n// including history listeners and kicking off the initial data fetch\nlet router = createRouter({\n  // Routes array\n  routes: ,\n  // History instance\n  history,\n}).initialize()\n```\n\nInternally, 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()`;\n\n```ts\ninterface RouterState {\n  // False during the initial data load, true once we have our initial data\n  initialized: boolean;\n  // The `history` action of the most recently completed navigation\n  historyAction: Action;\n  // The current location of the router.  During a navigation this reflects\n  // the \"old\" location and is updated upon completion of the navigation\n  location: Location;\n  // The current set of route matches\n  matches: DataRouteMatch[];\n  // The state of the current navigation\n  navigation: Navigation;\n  // The state of any in-progress router.revalidate() calls\n  revalidation: RevalidationState;\n  // Data from the loaders for the current matches\n  loaderData: RouteData;\n  // Data from the action for the current matches\n  actionData: RouteData | null;\n  // Errors thrown from loaders/actions for the current matches\n  errors: RouteData | null;\n  // Map of all active fetchers\n  fetchers: Map<string, Fetcher>;\n  // Scroll position to restore to for the active Location, false if we\n  // should not restore, or null if we don't have a saved position\n  // Note: must be enabled via router.enableScrollRestoration()\n  restoreScrollPosition: number | false | null;\n  // Proxied `preventScrollReset` value passed to router.navigate()\n  preventScrollReset: boolean;\n}\n```\n\n### Navigations\n\nAll navigations are done through the `router.navigate` API which is overloaded to support different types of navigations:\n\n```js\n// Link navigation (pushes onto the history stack by default)\nrouter.navigate(\"/page\");\n\n// Link navigation (replacing the history stack)\nrouter.navigate(\"/page\", { replace: true });\n\n// Pop navigation (moving backward/forward in the history stack)\nrouter.navigate(-1);\n\n// Form submission navigation\nlet formData = new FormData();\nformData.append(key, value);\nrouter.navigate(\"/page\", {\n  formMethod: \"post\",\n  formData,\n});\n```\n\n### Fetchers\n\nFetchers are a mechanism to call loaders/actions without triggering a navigation, and are done through the `router.fetch()` API. All fetch calls require a unique key to identify the fetcher.\n\n```js\n// Execute the loader for /page\nrouter.fetch(\"key\", \"/page\");\n\n// Submit to the action for /page\nlet formData = new FormData();\nformData.append(key, value);\nrouter.fetch(\"key\", \"/page\", {\n  formMethod: \"post\",\n  formData,\n});\n```\n\n### Revalidation\n\nBy 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.\n\n[react-router]: https://reactrouter.com\n[remix]: https://remix.run\n[react-router-repo]: https://github.com/remix-run/react-router\n[remix-routers-repo]: https://github.com/brophdawg11/remix-routers\n","engines":{"node":">=14"},"gitHead":"23193a43256982c0675815eda6f112c18b407f8f","_npmUser":{"name":"mjackson","email":"npm@mjackson.me"},"repository":{"url":"git+https://github.com/remix-run/react-router.git","type":"git","directory":"packages/router"},"_npmVersion":"8.19.3","description":"Nested/Data-driven/Framework-agnostic Routing","directories":{},"sideEffects":false,"_nodeVersion":"16.19.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.0.0-experimental-b162e81d_1679072327997_0.9167119251812241","host":"s3://npm-registry-packages"},"publish_time":1679072328226,"_cnpm_publish_time":1679072328226,"dist-tags":{"experimental":"0.0.0-experimental-f21d91eb3","latest":"1.23.4","next":"0.1.0","pre":"1.21.1-pre.0","pre-v6":"1.23.2-pre-v6.0","version-6":"1.23.2"}}