{"name":"@remix-run/router","version":"0.2.0-pre.0","keywords":["remix","router","location"],"author":{"name":"Remix Software","email":"hello@remix.run"},"license":"MIT","_id":"@remix-run/router@0.2.0-pre.0","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":"a2b2acf8a7382f98142b5c816bfba4f6e060e8cf","tarball":"http://registry-npm.ywwl.com/@remix-run/router/download/@remix-run/router-0.2.0-pre.0.tgz","fileCount":38,"integrity":"sha512-WDvE6Jvp8S+nuGb8pgrsYeCpX5HvZcgI6upbfNK2ZY1kyCYxWjGi574mfhb9rf4HDja5nqj4A80oJ3EkhjbKUQ==","signatures":[{"sig":"MEQCIDDYSoEsa9CNOVfw9J/OFL9ELA2HgyS8r5akmUiK2R/NAiBB7eP0TfLE8by+yG1gOc5ZGEbIJfsLJnmWecl+Bkssfw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":332765,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJinmcsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpyFA/+LBwTYr454mu7QEH/+8I4uD/Rbsn2+FNdM+7ZA+EFM68E+9GD\r\nA6dysKfVJpSB/ZKqM8ufDPtkfcD7Quj1piOF25dO3/TElTxzvyHaJhyQRYQJ\r\nuAI8KKj0Zf1Q/0O+R9EB1TK1+CC34p+x6lgyCJrVZrY8sSHBQJKBcmfsQPhD\r\nfa8OdXJXwVrU7xTE/3pgPq6l9E3hFv4qNF7tpZTrGZ/Fhp2ZJhILonrQ89ID\r\nXK1aXhA/STwldJLZWlHGSiQFGRnBwUxXXb+WST0dn5C7OGsqtZ8jvgi3wabd\r\niKOSrCd+MbTCQ2/7qkkYljweZQGNQln1gLKpvbBiFtzgl2hOfVKUfRhlyJ58\r\nLjZ4R2p2QPTGA7pa8uGwuRuPZN+WY5mDVBs4r6zmarsX3LO40b3dO/3JGzNz\r\nN5Y4syJm2oNcPIwwQgvFiWjvYQdB1o8rp1AL6qxg1Xmw0jtfYacG+lOBOC9L\r\nsR/sdRSMDiCB315QLwS6bIXy6PAW1M8Px+GmBLIBYJk91JieaOlQU1b8wBCd\r\nTZfilAOZEgz0EdjlZ9FvOXyXpRUdkOzVI7+4HWcP5sD2zXl4MBT0TkWXTfvs\r\ncNw/J5Rco35wLbUxew/LEPZ9/06URZ3usmlLOO2es0h4kA5RE7lWhCWM21bO\r\nlMJbB7sJCvPuzL/ZKZvJuoKKodJY+TmpHxk=\r\n=rR0r\r\n-----END PGP SIGNATURE-----\r\n","size":53574,"noattachment":false,"key":"/@remix-run/router/-/@remix-run/router-0.2.0-pre.0.tgz"},"main":"./main.js","types":"./index.d.ts","unpkg":"./umd/router.production.min.js","module":"./index.js","readme":"# Router\n\nThe `@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.\n\nIf you're using React Router, you should never `import` anything directly from\nthe `@remix-run/router` or `react-router` packages, but you should have everything\nyou need in either `react-router-dom` or `react-router-native`. Both of those\npackages re-export everything from `@remix-run/router` and `react-router`.\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 using react-router RouteObject's\n  routes,\n  // History instance\n  history,\n  // Optional hydration data for SSR apps\n  hydrationData?: HydrationState;\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  // 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  // False during the initial data load, true once we have our initial data\n  initialized: boolean;\n  // The state of the current navigation\n  navigation: Navigation;\n  // The state of an in-progress router.revalidate() calls\n  revalidation: RevalidationState;\n  // Scroll position to restore to for the active Location, false if we\n  // should not restore,m 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 `resetScroll` value passed to router.navigate() (default true)\n  resetScrollPosition: boolean;\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}\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","gitHead":"12a662dbb537e28627e942eb86c85fe36124f652","_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.5.5","description":"Nested/Data-driven/Framework-agnostic Routing","directories":{},"sideEffects":false,"_nodeVersion":"16.15.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/router_0.2.0-pre.0_1654548268501_0.8224247899594008","host":"s3://npm-registry-packages"},"publish_time":1654548268687,"_cnpm_publish_time":1654548268687,"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"}}