{"id":13719413,"url":"https://github.com/arisris/next-api-router","last_synced_at":"2026-02-19T16:39:23.756Z","repository":{"id":57098690,"uuid":"450317908","full_name":"arisris/next-api-router","owner":"arisris","description":"Simple router for Next.js api. inspired by itty-router","archived":false,"fork":false,"pushed_at":"2022-01-22T06:28:53.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-20T16:53:18.443Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arisris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-21T01:46:14.000Z","updated_at":"2022-01-21T02:50:27.000Z","dependencies_parsed_at":"2022-08-20T17:31:19.655Z","dependency_job_id":null,"html_url":"https://github.com/arisris/next-api-router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arisris/next-api-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arisris%2Fnext-api-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arisris%2Fnext-api-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arisris%2Fnext-api-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arisris%2Fnext-api-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arisris","download_url":"https://codeload.github.com/arisris/next-api-router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arisris%2Fnext-api-router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29622279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T13:04:20.082Z","status":"ssl_error","status_checked_at":"2026-02-19T13:03:33.775Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:00:48.249Z","updated_at":"2026-02-19T16:39:23.739Z","avatar_url":"https://github.com/arisris.png","language":"TypeScript","readme":"## Next.js Api Router\n\nA chainable router designed for Next.js api. inspired and regex based from itty-router\n\n### Features\n\n- [x] Tiny ([~8xx bytes](https://bundlephobia.com/package/@arisris/next-api-router) compressed) with zero dependencies.\n- [x] Strong typing with typescript also javascript with VSCode\n- [x] Anything is async/await handler\n- [x] Route params, with wildcards and optionals (e.g. `/base/:collection/:id?`)\n- [x] Middleware support\n- [x] By default error handler response is json\n- [x] Support anything of HTTP methods\n- [x] Chainable route declarations\n- [x] No dependencies\n\n### Installation\n\n```bash\nnpm i @arisris/next-api-router\n```\n\n### Example Usage\n\n```typescript\n// file: pages/api/[...any].ts\nimport NextApiRoute from \"@arisris/next-api-router\";\n\nexport default NextApiRoute({\n  key: \"all\", // a rest params default to \"any\"\n  timeout: 5000, // timeout in ms default to 10000ms\n  //onError: (error, req, res) =\u003e res.status(500).send(\"Internal Server Error\") // By default handled with json response\n})\n  .all(\"*\", async () =\u003e true) // middleware should return true\n  .get(\"/hello\", async (_, res) =\u003e res.send(\"Hello World\")) // simple\n  .get(\n    \"/wait\",\n    async () =\u003e await new Promise((resolve) =\u003e setTimeout(resolve, 3000)), // wait for 3000ms\n    async (_, res) =\u003e res.json({ msg: \"Done...\" })\n  )\n  .get(\"/error\", async () =\u003e {\n    throw new Error(\"OMG!\");\n  })\n  .get(\"/timeout\", async () =\u003e {\n    // No response is considered timeout\n  })\n  .get(\"/user/:name?\", async (req, res) =\u003e res.json({ params: req.params }))\n  // not found\n  .all(\"*\", async (_, res) =\u003e res.status(404).send(\"Not Found\"))\n  .handle; // Final handler of NextApiHandler\n```\n\n### Todo better documentation\n\n--\n\n### Links\n\n[My Website](https://arisris.com/)\n[itty-router](https://github.com/kwhitley/itty-router)\n","funding_links":[],"categories":["Open Source Project"],"sub_categories":["Utility"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farisris%2Fnext-api-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farisris%2Fnext-api-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farisris%2Fnext-api-router/lists"}