{"id":13761941,"url":"https://github.com/smeijer/next-runtime","last_synced_at":"2025-05-14T19:09:45.991Z","repository":{"id":37401533,"uuid":"405346310","full_name":"smeijer/next-runtime","owner":"smeijer","description":"All you need to handle POST requests, file uploads, and api requests, in Next.js getServerSideProps.","archived":false,"fork":false,"pushed_at":"2024-10-24T08:24:48.000Z","size":2945,"stargazers_count":589,"open_issues_count":11,"forks_count":20,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-01T06:02:36.616Z","etag":null,"topics":["api","forms","nextjs"],"latest_commit_sha":null,"homepage":"https://next-runtime.meijer.ws/","language":"TypeScript","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/smeijer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["smeijer"]}},"created_at":"2021-09-11T10:13:13.000Z","updated_at":"2025-02-11T15:51:24.000Z","dependencies_parsed_at":"2024-11-09T23:35:04.212Z","dependency_job_id":"42c82865-f9f4-436a-b8ad-64662ec1bd71","html_url":"https://github.com/smeijer/next-runtime","commit_stats":{"total_commits":123,"total_committers":9,"mean_commits":"13.666666666666666","dds":"0.16260162601626016","last_synced_commit":"44bf0c02c5b61149e67131bb47f92ceba60bf75b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smeijer%2Fnext-runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smeijer%2Fnext-runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smeijer%2Fnext-runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smeijer%2Fnext-runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smeijer","download_url":"https://codeload.github.com/smeijer/next-runtime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253672698,"owners_count":21945480,"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":["api","forms","nextjs"],"created_at":"2024-08-03T14:00:31.829Z","updated_at":"2025-05-14T19:09:44.834Z","avatar_url":"https://github.com/smeijer.png","language":"TypeScript","funding_links":["https://github.com/sponsors/smeijer"],"categories":["Nextjs Projects","TypeScript"],"sub_categories":[],"readme":"![banner](docs/public/banner.png)\n\nAll you need to handle `POST` requests and file uploads in [`getServerSideProps`](https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering).\n\n## Documentation\n\nAll documentation and guides can be found at [next-runtime.meijer.ws](https://next-runtime.meijer.ws/).\n\n## Features\n\nnext-runtime aims to move more logic to the \"runtime part\" of your Next.js server, and less static site generation. With proper cache headers, every server is an (incremental) static site generator.\n\nTo achieve that, we provide you a convenient API to:\n\n- Handle POST requests in `getServerSideProps`.\n- Handle file uploads in `getServerSideProps`.\n- Easily manage headers and cookies.\n- Reuse `getServerSideProps` as zero-config JSON api.\n\n## Usage\n\nIn case you're not the documentation type of person, here's a quick example to get you up and running. Please consult [the docs](https://next-runtime.meijer.ws/) if this leaves you with questions.\n\n```js\nimport fs from 'fs';\nimport { handle, json } from 'next-runtime';\n\nexport const getServerSideProps = handle({\n  async upload({ file, stream }) {\n    stream.pipe(fs.createWriteStream(`/uploads/${file.name}`));\n  },\n\n  async get({ params, query }) {\n    return json({ name: 'Stephan Meijer' });\n  },\n\n  async post({ req: { body } }) {\n    return json({ message: 'Thanks for your submission!' });\n  },\n});\n\nexport default function Home({ name, message }) {\n  if (message) {\n    return \u003cp\u003e{message}\u003c/p\u003e;\n  }\n\n  return (\n    \u003cform method=\"post\" encType=\"multipart/form-data\"\u003e\n      \u003cinput name=\"name\" defaultValue={name} /\u003e\n      \u003cinput type=\"file\" name=\"file\" /\u003e\n      \u003cbutton type=\"submit\"\u003esubmit\u003c/button\u003e\n    \u003c/form\u003e\n  );\n}\n```\n\n## Sponsor\n\nAre you, or your employer, a satisfied user of this, or any of [my other projects](https://meijer.ws/open-source). Then please [consider sponsoring](https://github.com/sponsors/smeijer) my work so I can dedicate more time to maintaining this kind of projects.\n\n## Contributing\n\nPlease check [contributing.md](/CONTRIBUTING.md). It contains info about the structure of this repo\nto help you get up and running.\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/smeijer\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1196524?v=4?s=100\" width=\"100px;\" alt=\"Stephan Meijer\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eStephan Meijer\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=smeijer\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=smeijer\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#ideas-smeijer\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"#infra-smeijer\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e \u003ca href=\"#maintenance-smeijer\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://gal.hagever.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/2054772?v=4?s=100\" width=\"100px;\" alt=\"Gal Schlezinger\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eGal Schlezinger\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=Schniz\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"http://mapleleaf.dev\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/19603573?v=4?s=100\" width=\"100px;\" alt=\"Darius\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDarius\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=itsMapleLeaf\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=itsMapleLeaf\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"http://umarahmed.dev\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/8302959?v=4?s=100\" width=\"100px;\" alt=\"Umar Ahmed\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eUmar Ahmed\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=umar-ahmed\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"http://www.a-tm.co.jp/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/15067920?v=4?s=100\" width=\"100px;\" alt=\"HIKARU KOBORI\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eHIKARU KOBORI\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=anneau\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/KoichiKiyokawa\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/40315079?v=4?s=100\" width=\"100px;\" alt=\"Koichi Kiyokawa\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKoichi Kiyokawa\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=KoichiKiyokawa\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=KoichiKiyokawa\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"http://gorkacesium.substack.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/804301?v=4?s=100\" width=\"100px;\" alt=\"Gorka Cesium\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eGorka Cesium\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=vasco3\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"http://efficientuser.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/6157834?v=4?s=100\" width=\"100px;\" alt=\"Pandiyan Murugan\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePandiyan Murugan\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/smeijer/next-runtime/commits?author=PandiyanCool\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmeijer%2Fnext-runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmeijer%2Fnext-runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmeijer%2Fnext-runtime/lists"}