{"_id":"@elliottsj/next-routes","_rev":"2-6c82ca54250905a92ef63095b1451240","name":"@elliottsj/next-routes","dist-tags":{"latest":"1.4.4"},"versions":{"1.4.3":{"name":"@elliottsj/next-routes","version":"1.4.3","description":"Easy to use universal dynamic routes for Next.js","repository":{"type":"git","url":"git+https://github.com/elliottsj/next-routes.js.git"},"publishConfig":{"access":"public"},"main":"dist","typings":"typings/next-routes.d.ts","scripts":{"lint":"standard 'src/*' 'test/*'","build":"del dist/* && babel src -d dist","prepublishOnly":"npm run test","pretest":"npm run lint && npm run build","test":"npm run testOnly && npm run testTypings","testOnly":"jest \\.test.js --coverage","testTypings":"tsc --project ./typings/tests","testCI":"npm run test && cat coverage/lcov.info | coveralls","dev":"concurrently -k 'npm run build -- -w' 'npm run testOnly -- --watch'"},"standard":{"parser":"babel-eslint"},"jest":{"testEnvironment":"node","roots":["test/","dist/"]},"dependencies":{"path-to-regexp":"^2.1.0"},"peerDependencies":{"next":">=2","react":"^15.4.2 || ^16"},"devDependencies":{"@babel/cli":"^7.0.0-beta.47","@babel/core":"^7.0.0-beta.47","@babel/preset-env":"^7.0.0-beta.47","@types/next":"^2.4.8","@types/node":"^10.1.2","babel-core":"^7.0.0-bridge.0","babel-eslint":"^8.2.1","babel-jest":"^22.4.3","concurrently":"^3.5.0","coveralls":"^3.0.0","del-cli":"^1.1.0","jest":"^22.4.3","next":"^6.0.0","prop-types":"^15.6.0","react":"^16.0.0","react-dom":"^16.0.0","react-test-renderer":"^16.0.0","standard":"^11.0.1","typescript":"^2.7.2"},"author":{"name":"fridays"},"license":"MIT","keywords":["next","next.js","react","route","router","routes","routing"],"gitHead":"700605a23e0fff5a0c50ea2f74f3163487d1f7d9","bugs":{"url":"https://github.com/elliottsj/next-routes.js/issues"},"homepage":"https://github.com/elliottsj/next-routes.js#readme","_id":"@elliottsj/next-routes@1.4.3","_npmVersion":"6.4.1","_nodeVersion":"10.8.0","_npmUser":{"name":"elliottsj","email":"me@elliottsj.com"},"dist":{"integrity":"sha512-QZh+bfUtU3Jvos9IU46Lw5c+sJ8VQCOmzJWeKmzmkIA5DruZ4KwCYXsOnca0UKyCwvWZUMaXaDnwUc/7IbEjQA==","shasum":"9a65f25cd35ca5f63d90d8a82132787ce2c67dd2","tarball":"https://registry.npmjs.org/@elliottsj/next-routes/-/next-routes-1.4.3.tgz","fileCount":8,"unpackedSize":20834,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbxLrjCRA9TVsSAnZWagAAB+EP/3H2VhVhLcD3cnlkKq4G\nthsD5h4lKgy70zYCR3GidNZdEkm0D/v/Qk3nwRTkKFn8dkzciU8fmwflDuQD\n6j0NG860YL3fBxnxQ2ET88IdcYjw64FQOGYzPiCx+TtwwcdAuc+OmuC0Lg+X\nPjoiksFpxE7BaEYlbldjsTSBALI1OsP6kLsrNrjAQeBFKJ5UV7UAjgBxaRlS\nALSSz9hOFpsQwSSl58llQAjkMlMS8zw8oNN4MaOE5+CauB3l0MvRmlpZ+0Bh\nZHqIYVplm7wT9ai2qJrYdZ6tTzbL7fWjxHL/RYs8BixVJEnTtbkCuM8sNwlj\nHSJ7XYHVywbytc9kcmhxZAazZfSNGfQl1GVj6ZHa6KQyr7FPf5BPldmA5y5D\nkf0g9+B7zN9Vz6DSfB9AdmVQBzjScAlsjmTDbRl8Tu9Uf5/VpZr219ndbo3/\nPxOsahTLL+w0MR/ubcALdXehylqa9yzZKGk1HVz7afJFl//N257dD899CHwb\nmFIYVECbP5gkp65Q48gJPTiS58mvdpef62qVeZHu2/aJ+FeuIduMq5NhiMvK\n86567rdUqJZpm0/6IB6xBoaxklKFTfyCd4FKSHbu5lkHL/L1wXOXeh/8D6ZO\nSS0H68VMs1EDZDaSxTu9qw9SJQ0LeNqvokSt6rL+Gory/xkTH0dn5H5CS9ks\nT4CG\r\n=sKnx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBX5Q80lNncUSXIYII21XAbDlpYIiGe0ob0rzNbUgfKSAiEAzKXO+2P62h3YdcB5YCyNBcaI4n596aIK3NQYP2z5cWM="}]},"maintainers":[{"name":"elliottsj","email":"me@elliottsj.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-routes_1.4.3_1539619554507_0.7722719573482353"},"_hasShrinkwrap":false},"1.4.4":{"name":"@elliottsj/next-routes","version":"1.4.4","description":"Easy to use universal dynamic routes for Next.js","repository":{"type":"git","url":"git+https://github.com/elliottsj/next-routes.js.git"},"publishConfig":{"access":"public"},"main":"dist","typings":"typings/next-routes.d.ts","scripts":{"lint":"standard 'src/*' 'test/*'","build":"del dist/* && babel src -d dist","prepublishOnly":"npm run test","pretest":"npm run lint && npm run build","test":"npm run testOnly && npm run testTypings","testOnly":"jest \\.test.js --coverage","testTypings":"tsc --project ./typings/tests","dev":"concurrently -k 'npm run build -- -w' 'npm run testOnly -- --watch'"},"standard":{"parser":"babel-eslint"},"jest":{"testEnvironment":"node","roots":["test/","dist/"]},"dependencies":{"path-to-regexp":"^2.1.0"},"peerDependencies":{"next":">=2","react":"^15.4.2 || ^16"},"devDependencies":{"@babel/cli":"^7.0.0-beta.47","@babel/core":"^7.0.0-beta.47","@babel/preset-env":"^7.0.0-beta.47","@types/next":"^2.4.8","@types/node":"^10.1.2","babel-core":"^7.0.0-bridge.0","babel-eslint":"^8.2.1","babel-jest":"^22.4.3","concurrently":"^3.5.0","del-cli":"^1.1.0","jest":"^22.4.3","next":"^6.0.0","prop-types":"^15.6.0","react":"^16.0.0","react-dom":"^16.0.0","react-test-renderer":"^16.0.0","standard":"^11.0.1","typescript":"^2.7.2"},"author":{"name":"fridays"},"license":"MIT","keywords":["next","next.js","react","route","router","routes","routing"],"gitHead":"6326db3f8e9f07a5fd38db496bf3cf843da53054","bugs":{"url":"https://github.com/elliottsj/next-routes.js/issues"},"homepage":"https://github.com/elliottsj/next-routes.js#readme","_id":"@elliottsj/next-routes@1.4.4","_npmVersion":"6.4.1","_nodeVersion":"10.8.0","_npmUser":{"name":"elliottsj","email":"me@elliottsj.com"},"dist":{"integrity":"sha512-TfRb5GyDjq34zUEPMltBbLBb59yPIKpDpYsPkKw191qCdAS9YTnLGBTc5DBdE3gdMGBFZ41beqZtu62+bq2QbA==","shasum":"805b043200610a7d3c5291cd45560d454a67bd07","tarball":"https://registry.npmjs.org/@elliottsj/next-routes/-/next-routes-1.4.4.tgz","fileCount":8,"unpackedSize":21068,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbxNj8CRA9TVsSAnZWagAA1KYP/2ZRSUUKpIbETxTmcUb0\nKm9tUQdGOrbNiwB8E+yb/I2XTuatfAt+tNDjCxgl/1oAEB/Kpia7Mt9UGmDK\nPHnwKaAmdpI4jzR12qGcLNOpnYT2/F1EmIMD18PiI6EAI2aLuSnn4iMKWvxC\nadrUrbY46LHryP8KqFSH7y2pLgKuMXuRt62ym+yquqU8CD1JA+1md05E6pF8\n9ImFhPBKLyaY9rOYU2E/SdB2Rrf3NMQ2D4xrzePXFnd+qpWUH1Ovon7Nbzbu\nRiBLEtXLhKDIILWRUtsqM1KptUfpj13UAdSsDtZL0tgiLpk8mUO7HMApNt0N\nwVU+vr16iHTZM/j522Gn1aC+kLWByNOXyBUWibozwa0IHmTADVlzxeBYYEwB\nwIjAU94Eht4EIGa6qjfeDQdpUrPkomGWdxxhs/K7ZbEp188G/5S/NT9FRkpz\nOJ7MpVCUMYEYh4ztw+wRUDGeflw6FMsZz27qqb2WBBHXNn1GpAGPn8wLSqwZ\n7ifoz94PWLlspIklGeonmVmvzraCGXzfYZORTEywWW9ZLz+L4ZgjCPoflRcF\ngNO9dcMKQLBjrjTlHw9sM7+bj3bwDsGVkgL/2hxFdCwiKxg6+UZOCRoQ9aGE\nD6I4Zi4aBrMpIdfiUojK7SjbuY30t0HGc5F8uIVc/LUpjUxEtAlPUs4cVk/q\ntUJD\r\n=i0OV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCywq7DGE48WPRNpHK157EAaeo+RHnHKACr2fOAW93XUwIhAJm7bspTtduMzwEgjK1fb5tx02r1pLHlHxs8d8WXs1Kt"}]},"maintainers":[{"name":"elliottsj","email":"me@elliottsj.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-routes_1.4.4_1539627259618_0.4973557460518405"},"_hasShrinkwrap":false}},"time":{"created":"2018-10-15T16:05:54.354Z","1.4.3":"2018-10-15T16:05:54.666Z","modified":"2022-04-05T07:20:24.335Z","1.4.4":"2018-10-15T18:14:19.756Z"},"maintainers":[{"name":"elliottsj","email":"me@elliottsj.com"}],"description":"Easy to use universal dynamic routes for Next.js","homepage":"https://github.com/elliottsj/next-routes.js#readme","keywords":["next","next.js","react","route","router","routes","routing"],"repository":{"type":"git","url":"git+https://github.com/elliottsj/next-routes.js.git"},"author":{"name":"fridays"},"bugs":{"url":"https://github.com/elliottsj/next-routes.js/issues"},"license":"MIT","readme":"# Dynamic Routes for Next.js\n\n**NOTICE: This is a fork of [fridays/next-routes](https://github.com/fridays/next-routes). This will continue to be maintained until [fridays/next-routes](https://github.com/fridays/next-routes) becomes maintained again. See https://github.com/fridays/next-routes/issues/244.**\n\n[![npm (scoped)](https://img.shields.io/npm/v/@elliottsj/next-routes.svg)](https://www.npmjs.com/package/@elliottsj/next-routes) [![Build Status](https://travis-ci.com/elliottsj/next-routes.svg?branch=master)](https://travis-ci.com/elliottsj/next-routes)\n\nEasy to use universal dynamic routes for [Next.js](https://github.com/zeit/next.js)\n\n- Express-style route and parameters matching\n- Request handler middleware for express & co\n- `Link` and `Router` that generate URLs by route definition\n\n## How to use\n\nInstall:\n\n```bash\nnpm install @elliottsj/next-routes --save\n```\n\nCreate `routes.js` inside your project:\n\n```javascript\nconst routes = require('@elliottsj/next-routes')\n\n                                                    // Name   Page      Pattern\nmodule.exports = routes()                           // ----   ----      -----\n.add('about')                                       // about  about     /about\n.add('blog', '/blog/:slug')                         // blog   blog      /blog/:slug\n.add('user', '/user/:id', 'profile')                // user   profile   /user/:id\n.add('/:noname/:lang(en|es)/:wow+', 'complex')      // (none) complex   /:noname/:lang(en|es)/:wow+\n.add({name: 'beta', pattern: '/v3', page: 'v3'})    // beta   v3        /v3\n```\n\nThis file is used both on the server and the client.\n\nAPI:\n\n- `routes.add([name], pattern = /name, page = name)`\n- `routes.add(object)`\n\nArguments:\n\n- `name` - Route name\n- `pattern` - Route pattern (like express, see [path-to-regexp](https://github.com/pillarjs/path-to-regexp))\n- `page` - Page inside `./pages` to be rendered\n\nThe page component receives the matched URL parameters merged into `query`\n\n```javascript\nexport default class Blog extends React.Component {\n  static async getInitialProps ({query}) {\n    // query.slug\n  }\n  render () {\n    // this.props.url.query.slug\n  }\n}\n```\n\n## On the server\n\n```javascript\n// server.js\nconst next = require('next')\nconst routes = require('./routes')\nconst app = next({dev: process.env.NODE_ENV !== 'production'})\nconst handler = routes.getRequestHandler(app)\n\n// With express\nconst express = require('express')\napp.prepare().then(() => {\n  express().use(handler).listen(3000)\n})\n\n// Without express\nconst {createServer} = require('http')\napp.prepare().then(() => {\n  createServer(handler).listen(3000)\n})\n```\n\nOptionally you can pass a custom handler, for example:\n\n```javascript\nconst handler = routes.getRequestHandler(app, ({req, res, route, query}) => {\n  app.render(req, res, route.page, query)\n})\n```\n\nMake sure to use `server.js` in your `package.json` scripts:\n\n```json\n\"scripts\": {\n  \"dev\": \"node server.js\",\n  \"build\": \"next build\",\n  \"start\": \"NODE_ENV=production node server.js\"\n}\n```\n\n## On the client\n\nImport `Link` and `Router` from your `routes.js` file to generate URLs based on route definition:\n\n### `Link` example\n\n```jsx\n// pages/index.js\nimport {Link} from '../routes'\n\nexport default () => (\n  <div>\n    <div>Welcome to Next.js!</div>\n    <Link route='blog' params={{slug: 'hello-world'}}>\n      <a>Hello world</a>\n    </Link>\n    or\n    <Link route='/blog/hello-world'>\n      <a>Hello world</a>\n    </Link>\n  </div>\n)\n```\n\nAPI:\n\n- `<Link route='name'>...</Link>`\n- `<Link route='name' params={params}> ... </Link>`\n- `<Link route='/path/to/match'> ... </Link>`\n\nProps:\n\n- `route` - Route name or URL to match (alias: `to`)\n- `params` - Optional parameters for named routes\n\nIt generates the URLs for `href` and `as` and renders `next/link`. Other props like `prefetch` will work as well.\n\n### `Router` example\n\n```jsx\n// pages/blog.js\nimport React from 'react'\nimport {Router} from '../routes'\n\nexport default class Blog extends React.Component {\n  handleClick () {\n    // With route name and params\n    Router.pushRoute('blog', {slug: 'hello-world'})\n    // With route URL\n    Router.pushRoute('/blog/hello-world')\n  }\n  render () {\n    return (\n      <div>\n        <div>{this.props.url.query.slug}</div>\n        <button onClick={this.handleClick}>Home</button>\n      </div>\n    )\n  }\n}\n```\n\nAPI:\n\n- `Router.pushRoute(route)`\n- `Router.pushRoute(route, params)`\n- `Router.pushRoute(route, params, options)`\n\nArguments:\n\n- `route` - Route name or URL to match\n- `params` - Optional parameters for named routes\n- `options` - Passed to Next.js\n\nThe same works with `.replaceRoute()` and `.prefetchRoute()`\n\nIt generates the URLs and calls `next/router`\n\n---\n\nOptionally you can provide custom `Link` and `Router` objects, for example:\n\n```javascript\nconst routes = module.exports = require('@elliottsj/next-routes')({\n  Link: require('./my/link')\n  Router: require('./my/router')\n})\n```\n\n---\n\n##### Related links\n\n- [zeit/next.js](https://github.com/zeit/next.js) - Framework for server-rendered React applications\n- [path-to-regexp](https://github.com/pillarjs/path-to-regexp) - Express-style path to regexp\n","readmeFilename":"README.md"}