{"_id":"react-mux","_rev":"166-e9dc57cf5d009c77993e8305f648ba26","name":"react-mux","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.1":{"name":"react-mux","version":"0.1.1","keywords":["router","react","transition","suspense","typesafe","typescript"],"author":{"name":"Zuma206"},"license":"MIT","_id":"react-mux@0.1.1","maintainers":[{"name":"zuma206","email":"james.peedle@yahoo.com"}],"dist":{"shasum":"f39e2d515bead3adf5c4dabd521c0af05eb952fe","tarball":"https://registry.npmjs.org/react-mux/-/react-mux-0.1.1.tgz","fileCount":17,"integrity":"sha512-2SKuxZPKv7wrsB69gbgNmdvhcQmnGX05jMB407W+38LE3tp7/5TjOoqC5XvX0It6V3AY4DiNVHayxNDjoDlb+A==","signatures":[{"sig":"MEYCIQD072yJSGmhmCwsqmI9NE2D+6Rtj+Lq5S0VvxWkiPz1xwIhANUD4ZnumbA+zpHCEygKGNEeet4Sd0BWCQ0G0UoMt40Q","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36923},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"c3ead9f7e8e6809eaaa2d875bf3527ee802c0561","scripts":{"build":"tsc && tsup"},"_npmUser":{"name":"zuma206","email":"james.peedle@yahoo.com"},"_npmVersion":"10.8.1","description":"Finally, a modern typesafe react router","directories":{},"_nodeVersion":"20.16.0","dependencies":{"regexparam":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","tslib":"^2.7.0","typescript":"^5.6.2","@types/react":"^18.3.8"},"peerDependencies":{"react":">=18.3.1"},"_npmOperationalInternal":{"tmp":"tmp/react-mux_0.1.1_1726845755419_0.08398469790216301","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"react-mux","version":"0.1.3","keywords":["router","react","transition","suspense","typesafe","typescript"],"author":{"name":"Zuma206"},"license":"MIT","_id":"react-mux@0.1.3","maintainers":[{"name":"zuma206","email":"james.peedle@yahoo.com"}],"dist":{"shasum":"8a33869da0bc2f3c9c39ded28c2c61d2afc52606","tarball":"https://registry.npmjs.org/react-mux/-/react-mux-0.1.3.tgz","fileCount":17,"integrity":"sha512-8AKTXiWAQAF/fcaI4ZncH1t+vLeBuwhsIWf/0QcRLxyrjzYZr2DpUytHo8paAHia8Go95nTNnQ1mNDcv25hQpQ==","signatures":[{"sig":"MEUCIQDzHHrOWn9Bn2tITBct+3cfj7L77pblry/qs27FFJlVeQIgTX2A72wRAXdOxbGSzms2psZ3ozVHTqaWsN4cGFCue5k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":40632},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"dbefbd8881d54849391608166b2447705bac5849","scripts":{"build":"tsc && tsup"},"_npmUser":{"name":"zuma206","email":"james.peedle@yahoo.com"},"_npmVersion":"10.8.1","description":"Finally, a modern typesafe react router","directories":{},"_nodeVersion":"20.16.0","dependencies":{"regexparam":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","tslib":"^2.7.0","typescript":"^5.6.2","@types/react":"^18.3.8"},"peerDependencies":{"react":">=18.3.1"},"_npmOperationalInternal":{"tmp":"tmp/react-mux_0.1.3_1726849574699_0.7205038803863768","host":"s3://npm-registry-packages"}},"0.1.4":{"name":"react-mux","version":"0.1.4","keywords":["router","react","transition","suspense","typesafe","typescript"],"author":{"name":"Zuma206"},"license":"MIT","_id":"react-mux@0.1.4","maintainers":[{"name":"zuma206","email":"james.peedle@yahoo.com"}],"dist":{"shasum":"3f63ca249e471ce57dc602dc2ec6cd7b77da111d","tarball":"https://registry.npmjs.org/react-mux/-/react-mux-0.1.4.tgz","fileCount":17,"integrity":"sha512-8N+7H2KWv1XTWSHg5C3EFX8E74CZcyCupKWTxVDOPLQ/zErcYP9Y92o9Do31OowKB8YwOAKm9J2vhDfahFB2+g==","signatures":[{"sig":"MEUCIQCR6KkrQxvUQiEiaDdgwwoqZdoTnmUnFpcCspxWtukfHgIgOP1lZrYolpMCPBGLHo3yG4FDqyE7HoOLbpa5/qan7SI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":40611},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"5e01d2f1804a6feeb9501ad2ac3e9058e9af9aba","scripts":{"build":"tsc && tsup"},"_npmUser":{"name":"zuma206","email":"james.peedle@yahoo.com"},"_npmVersion":"10.8.1","description":"Finally, a modern typesafe react router","directories":{},"_nodeVersion":"20.16.0","dependencies":{"regexparam":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","tslib":"^2.7.0","typescript":"^5.6.2","@types/react":"^18.3.8"},"peerDependencies":{"react":">=18.3.1"},"_npmOperationalInternal":{"tmp":"tmp/react-mux_0.1.4_1726850390050_0.5189868645739035","host":"s3://npm-registry-packages"}},"0.1.5":{"name":"react-mux","version":"0.1.5","main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","scripts":{"build":"tsc && tsup"},"keywords":["router","react","transition","suspense","typesafe","typescript"],"author":{"name":"Zuma206"},"license":"MIT","description":"Finally, a modern typesafe react router","devDependencies":{"@types/react":"^18.3.8","tslib":"^2.7.0","tsup":"^8.3.0","typescript":"^5.6.2"},"peerDependencies":{"react":">=18.3.1"},"dependencies":{"regexparam":"^3.0.0"},"_id":"react-mux@0.1.5","gitHead":"4d85d12e732008e6cb78ecb5297d3f9fa70e2e70","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-BuspISXLPRlifAaAk1pf8tVTJNaV5FnULuwMqji9FCFksuki4N8cPEzs8+ZBMnorgeff6Yn4PefIC2RBs4Vvlw==","shasum":"efcef3fd89a34c6862a9d5cc1c119972e46a056d","tarball":"https://registry.npmjs.org/react-mux/-/react-mux-0.1.5.tgz","fileCount":17,"unpackedSize":40701,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICXEKaTvzSyiRJD+pzYp37SyQK/t/jpsApmTxtik5bipAiAXC6r7MUcW4t9bvcU2NJ65G/3rGI6EIm65IqxgKlkAuA=="}]},"_npmUser":{"name":"zuma206","email":"james.peedle@yahoo.com"},"directories":{},"maintainers":[{"name":"zuma206","email":"james.peedle@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-mux_0.1.5_1727017786029_0.04604848548834517"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-20T15:22:35.418Z","modified":"2024-09-22T15:09:46.485Z","1.0.0":"2016-01-14T04:22:28.505Z","0.1.0":"2016-01-14T04:24:33.645Z","0.1.0-alpha1":"2016-01-21T04:26:56.193Z","0.1.0-alpha2":"2016-01-21T06:00:52.338Z","0.1.0-alpha3":"2016-01-21T19:15:29.081Z","0.1.0-alpha4":"2016-01-21T21:09:30.425Z","0.1.0-alpha5":"2016-01-21T21:18:12.334Z","0.1.0-alpha7":"2016-01-21T22:30:58.833Z","0.1.0-alpha8":"2016-01-21T23:53:06.257Z","0.1.0-alpha10":"2016-01-22T05:41:16.521Z","0.1.0-alpha11":"2016-01-24T03:03:14.610Z","0.1.0-alpha12":"2016-01-26T00:11:10.071Z","0.1.0-alpha13":"2016-01-26T22:48:32.630Z","0.1.0-alpha14":"2016-01-27T00:37:21.383Z","0.1.0-alpha15":"2016-01-27T00:53:01.459Z","0.1.0-alpha16":"2016-01-27T20:23:06.493Z","0.1.0-alpha-16":"2016-01-27T22:33:27.891Z","0.1.0-alpha17":"2016-01-27T22:51:30.960Z","0.1.0-alpha18":"2016-01-27T23:59:29.584Z","0.1.0-alpha19":"2016-02-02T19:18:04.094Z","0.1.0-alpha20":"2016-02-04T01:25:43.912Z","0.1.0-alpha21":"2016-02-04T21:57:08.775Z","0.1.0-alpha22":"2016-02-05T00:23:35.940Z","0.1.0-alpha23":"2016-02-05T00:43:25.967Z","0.1.0-alpha24":"2016-02-05T00:55:09.084Z","0.1.0-alpha-24":"2016-02-05T01:07:54.696Z","0.1.0-alpha25":"2016-02-05T01:10:38.629Z","0.1.0-alpha26":"2016-02-05T01:18:01.586Z","0.1.0-alpha27":"2016-02-05T08:33:27.663Z","0.1.0-alpha28":"2016-02-05T22:50:41.613Z","0.1.0-alpha29":"2016-02-05T23:39:33.365Z","0.1.0-alpha30":"2016-02-06T00:09:06.809Z","0.1.0-alpha31":"2016-02-06T00:11:45.117Z","0.1.0-alpha32":"2016-02-06T00:26:27.678Z","0.2.0-alpha1":"2016-02-14T21:41:49.249Z","0.2.0-alpha2":"2016-02-14T22:56:09.291Z","0.2.0-alpha3":"2016-02-14T23:00:19.278Z","0.2.0-alpha4":"2016-02-14T23:08:20.811Z","0.2.0-alpha5":"2016-02-14T23:38:02.378Z","0.2.0-alpha6":"2016-02-15T20:13:04.740Z","0.2.0-alpha7":"2016-02-15T20:48:29.724Z","0.2.0-alpha8":"2016-02-15T22:59:30.735Z","0.2.0-alpha9":"2016-02-16T18:34:40.395Z","0.2.0-alpha10":"2016-02-16T22:43:31.016Z","0.2.0-alpha11":"2016-02-17T00:20:49.683Z","0.2.0-alpha12":"2016-02-17T00:43:41.545Z","0.2.0-alpha13":"2016-02-17T00:46:46.728Z","0.2.0-alpha14":"2016-02-18T01:19:47.327Z","0.2.0-alpha15":"2016-02-18T22:51:17.113Z","0.2.0-alpha16":"2016-02-22T17:56:13.583Z","0.2.0-alpha17":"2016-02-22T18:00:34.438Z","0.2.0-alpha18":"2016-02-22T19:43:35.727Z","0.2.0-alpha20":"2016-02-22T23:31:46.843Z","0.2.0-alpha21":"2016-02-23T00:21:06.790Z","0.2.0-alpha23":"2016-02-23T00:32:29.816Z","0.2.0-alpha24":"2016-02-23T00:35:41.727Z","0.2.0-alpha25":"2016-02-23T01:07:43.863Z","0.2.0-alpha26":"2016-02-23T21:22:39.707Z","0.2.0-alpha27":"2016-02-23T21:43:48.020Z","0.2.0-alpha28":"2016-02-23T22:07:16.903Z","0.2.0-alpha29":"2016-02-23T22:58:17.236Z","0.2.0-alpha30":"2016-02-23T23:05:08.746Z","0.2.0-alpha31":"2016-02-23T23:48:23.624Z","0.2.0-alpha32":"2016-02-23T23:58:28.287Z","0.2.0-alpha33":"2016-02-24T01:38:30.943Z","0.2.0-alpha34":"2016-02-24T19:45:19.674Z","0.2.0-alpha35":"2016-02-25T01:02:42.457Z","0.2.0-alpha36":"2016-02-25T18:56:05.924Z","0.2.0-alpha37":"2016-02-26T22:44:57.406Z","0.2.0-alpha38":"2016-02-29T19:46:34.569Z","0.2.0-alpha39":"2016-02-29T20:14:05.708Z","0.2.0-alpha40":"2016-02-29T20:43:18.944Z","0.2.0-alpha41":"2016-03-01T19:15:05.362Z","0.2.0-alpha42":"2016-03-02T00:51:46.985Z","0.2.0-alpha43":"2016-03-02T23:09:06.254Z","0.2.0-alpha44":"2016-03-03T20:27:03.450Z","0.2.0-alpha45":"2016-03-04T01:05:52.740Z","0.2.0-alpha46":"2016-03-04T20:27:34.871Z","0.2.0-alpha47":"2016-03-04T20:44:32.683Z","0.2.0-alpha48":"2016-03-05T00:44:27.558Z","0.2.0-alpha50":"2016-03-06T20:12:29.545Z","0.2.0-alpha51":"2016-03-06T20:27:25.335Z","0.2.0-alpha52":"2016-03-06T20:29:23.904Z","0.2.0-alpha53":"2016-03-06T21:30:39.664Z","0.2.0-alpha54":"2016-03-06T21:34:00.583Z","0.2.0-alpha55":"2016-03-07T00:45:57.736Z","0.2.0-alpha56":"2016-03-07T19:04:11.628Z","0.2.0-alpha57":"2016-03-07T19:56:44.384Z","0.2.0-alpha58":"2016-03-08T22:58:48.360Z","0.2.0-alpha59":"2016-03-09T00:26:24.145Z","0.2.0-alpha60":"2016-03-10T01:31:13.103Z","0.2.0-alpha61":"2016-03-10T19:37:34.921Z","0.2.0-alpha62":"2016-03-10T22:41:13.626Z","0.2.0-alpha63":"2016-03-11T19:47:08.378Z","0.2.0-alpha64":"2016-03-11T20:32:36.433Z","0.2.0-alpha65":"2016-03-11T20:38:14.233Z","0.2.0-alpha66":"2016-03-12T00:38:02.718Z","0.2.0-alpha67":"2016-03-12T00:55:48.065Z","0.2.0-alpha68":"2016-03-12T01:01:38.265Z","0.2.0-alpha69":"2016-03-13T00:29:55.985Z","0.2.0-alpha70":"2016-03-13T01:12:18.234Z","0.2.0-alpha71":"2016-03-13T01:28:31.500Z","0.2.0-alpha72":"2016-03-13T01:30:38.552Z","0.2.0-alpha73":"2016-03-13T20:55:30.718Z","0.2.0-alpha74":"2016-03-17T19:29:06.474Z","0.2.0-alpha75":"2016-03-17T19:34:17.897Z","0.2.0-alpha76":"2016-03-18T20:06:24.516Z","0.2.0-alpha77":"2016-03-21T22:24:29.199Z","0.2.0-alpha78":"2016-03-21T22:33:31.985Z","0.2.0-alpha79":"2016-03-21T22:37:59.347Z","0.2.0-alpha80":"2016-03-21T23:29:06.663Z","0.2.0-alpha-81":"2016-03-21T23:32:14.040Z","0.2.0-alpha83":"2016-03-21T23:43:26.777Z","0.2.0-alpha84":"2016-03-22T19:29:22.047Z","0.2.0-alpha85":"2016-03-22T19:59:06.458Z","0.2.0-alpha86":"2016-03-22T20:22:50.166Z","0.2.0-alpha87":"2016-03-22T20:36:59.580Z","0.2.0-alpha88":"2016-03-23T19:37:43.734Z","0.2.0-alpha89":"2016-03-23T20:18:59.805Z","0.2.0-alpha90":"2016-03-23T20:29:57.754Z","0.2.0-alpha91":"2016-03-23T20:49:46.991Z","0.2.0-alpha92":"2016-03-23T23:15:55.770Z","0.2.0-alpha93":"2016-04-07T19:54:56.235Z","0.2.0-alpha94":"2016-04-07T21:51:44.712Z","0.2.0-alpha95":"2016-04-07T21:59:00.775Z","0.2.0-alpha96":"2016-04-07T23:10:25.681Z","0.2.0-alpha-97":"2016-04-11T21:41:39.895Z","0.2.0-alpha97":"2016-04-12T23:42:39.647Z","0.2.0-alpha98":"2016-04-13T00:26:46.743Z","0.2.0-alpha99":"2016-04-13T21:50:32.235Z","0.2.0-alpha100":"2016-04-13T22:06:41.229Z","0.2.0-alpha101":"2016-04-13T22:35:14.683Z","0.2.0-alpha102":"2016-04-13T22:42:33.221Z","0.2.0-alpha103":"2016-04-13T22:51:47.900Z","0.2.0-alpha104":"2016-04-13T23:00:57.005Z","0.3.0-alpha0":"2016-04-13T23:32:57.712Z","0.3.0-alpha1":"2016-04-14T18:26:19.168Z","0.3.0-alpha2":"2016-04-14T19:29:13.726Z","0.3.0-alpha3":"2016-04-15T18:34:15.021Z","0.3.0-alpha4":"2016-04-15T19:26:39.278Z","0.3.0-alpha5":"2016-04-15T21:15:00.954Z","0.3.0-alpha6":"2016-04-15T22:13:47.488Z","0.3.0-alpha7":"2016-04-15T22:31:37.169Z","0.3.0-alpha8":"2016-04-15T22:48:53.507Z","0.3.0-alpha9":"2016-04-15T22:51:41.890Z","0.3.0-alpha10":"2016-04-15T23:36:42.192Z","0.3.0-alpha11":"2016-04-20T17:30:35.491Z","0.3.0-alpha12":"2016-04-20T17:39:28.334Z","0.3.0-alpha13":"2016-04-21T23:11:16.097Z","0.3.0-alpha14":"2016-04-22T01:02:26.223Z","0.3.0-alpha15":"2016-04-22T01:18:10.558Z","0.3.0-alpha16":"2016-04-22T18:13:29.601Z","0.3.0-alpha17":"2016-05-06T00:24:33.076Z","0.3.0-alpha18":"2016-08-03T16:38:02.979Z","0.0.0":"2024-04-04T16:23:56.932Z","0.0.1":"2024-09-18T02:15:06.980Z","0.1.1":"2024-09-20T15:22:35.640Z","0.1.2":"2024-09-20T16:17:12.259Z","0.1.3":"2024-09-20T16:26:14.908Z","0.1.4":"2024-09-20T16:39:50.227Z","0.1.5":"2024-09-22T15:09:46.211Z"},"author":{"name":"Zuma206"},"license":"MIT","keywords":["router","react","transition","suspense","typesafe","typescript"],"description":"Finally, a modern typesafe react router","maintainers":[{"name":"zuma206","email":"james.peedle@yahoo.com"}],"readme":"# React Mux\n\nReact Mux is the first transition based, suspense-compatible, typesafe router for react.\n\n## Get Started\n\n- `npm install react-mux`\n\n- Setup your router\n\n```ts\nimport { Router } from \"react-mux\";\nimport { Root } from \"./Root\";\nimport { lazy } from \"react\";\n\n// Fully compatible with lazy-loading\nconst Home = lazy(() => import(\"./routes/Home\"));\nconst About = lazy(() => import(\"./routes/About\"));\nconst Profile = lazy(() => import(\"./routes/Profile\"));\n\nexport const router = new Router();\n\n// Export routes so you can link to them in a typesafe manner\n// Also allows for easily changing at which path a route lives\n// Root wraps the home component as a layout\nexport const home = router.createRoute(\"/\", Home, Root);\n// These routes inherit the path and layout of home\nexport const about = home.extendRoute(\"about\", About);\n// Supports route params\nexport const profile = home.extendRoute(\"profile/:id\", Profile);\n```\n\n- Render your application\n\n```tsx\nimport { createRoot } from \"react-dom/client\";\nimport { RouterProvider } from \"react-mux\";\nimport { StrictMode } from \"react\";\nimport { router } from \"./router\";\n\ncreateRoot(document.getElementById(\"root\")!).render(\n  <StrictMode>\n    <RouterProvider path={location.pathname} router={router} />\n  </StrictMode>\n);\n```\n\n- Use typesafe links\n\n```tsx\nimport { profile } from \"../router\";\nimport { Link } from \"react-mux\";\n\nexport default function Home() {\n  return (\n    // Compile-time error if id is not specified\n    <Link to={profile} params={{ id: \"zuma\" }}>\n      Zuma's Profile\n    </Link>\n  );\n}\n```\n\n- Access typesafe params\n\n```tsx\nimport { useParams, useClientSideParams } from \"react-mux\";\nimport { profile } from \"../router\";\n\nexport default function Profile() {\n  // Use this for SSR or SPA apps\n  // Immediatly parses the URL, id is typesafe and always a string\n  const { id } = useParams(profile);\n\n  // Use this for SSG apps\n  // Parses the URL once the app is on the client and hydrated, id is typesafe but is string | undefined\n  // This allows you to pre-render dynamic routes, by initially setting all params to undefined\n  // Then the params become available once the page has loaded and is hydrated\n  const { id } = useClientSideParams(profile);\n\n  return <h1>{id}'s Profile</h1>;\n}\n```\n\n## Optional SSG\n\nReact mux was designed to allow for the pre-rendering of entire static routes, and the shells of dynamic routes. The static pages can then be served by your API server, such as a Go app. It's recommended the SSG is left to a meta framework such as NextJS or Astro.\n\n```tsx\n// Here is a generic psuedo-code example that can be applied to any framework\n// [...path].tsx\nimport { RouterProvider } from \"react-mux\";\nimport { router } from \"./router\";\n\n// Meta framework params sometimes come in as props\ntype Props = {\n  params: Record<string, string>;\n};\n\nexport default function page(props: Props) {\n  return <RouterProvider router={router} path={props.params.path} />;\n}\n\n// Use the router to generate one of each page\nexport function getStaticParams() {\n  // For dynamic routes, default any params to the value `$paramName`\n  // `useClientSideParams` can then be used to grab the actual param value later\n  return router.map((route) => route.path.replace(\":\", \"$\"));\n}\n```\n","readmeFilename":"README.md"}