{"id":18712879,"url":"https://github.com/mrsteele/next-middleware","last_synced_at":"2025-11-09T21:30:17.916Z","repository":{"id":57310589,"uuid":"113797110","full_name":"mrsteele/next-middleware","owner":"mrsteele","description":"Create middleware for your next route","archived":false,"fork":false,"pushed_at":"2017-12-14T22:26:27.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-21T09:39:33.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrsteele.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-11T01:12:18.000Z","updated_at":"2022-01-04T09:41:28.000Z","dependencies_parsed_at":"2022-09-08T05:20:55.036Z","dependency_job_id":null,"html_url":"https://github.com/mrsteele/next-middleware","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsteele%2Fnext-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsteele%2Fnext-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsteele%2Fnext-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsteele%2Fnext-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrsteele","download_url":"https://codeload.github.com/mrsteele/next-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239576797,"owners_count":19662113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-11-07T12:44:12.382Z","updated_at":"2025-11-09T21:30:17.835Z","avatar_url":"https://github.com/mrsteele.png","language":"JavaScript","readme":"# next-middleware\nCreate middleware for your next route\n\n### Install\n\nYou can install using npm\n\n```\nnpm i next-middleware --save\n```\n\n### Usage\n\nThe first step is to create your **middleware.js** file:\n\n```js\n// import this module\nimport Middleware from 'next-middleware'\n\n// Create a new middleware pipeline\nconst middleware = new Middleware()\n\n// we can go ahead and export the build function as the default\nexport default middleware.build\n\n// Add whatever middleware you want\nmiddleware.add(async ({ req }) =\u003e {\n  const users = fetch(`/users?id=${req.query.id}`)\n  return { users }\n})\n\n```\n\nThen you can use it anywhere in `/pages/*.js`\n\n```js\nimport middleware from '../middleware'\n\nconst Page = ({ users }) =\u003e (\n  \u003cdiv\u003e\n    Users: {users.map(user =\u003e user.name).join()}\n  \u003c/div\u003e\n)\n\n// wrap it with your middleware\nexport default middleware(Page)\n```\n\n### License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsteele%2Fnext-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrsteele%2Fnext-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsteele%2Fnext-middleware/lists"}