{"id":13808451,"url":"https://github.com/mars/heroku-nextjs-custom-server-express","last_synced_at":"2025-04-15T02:36:55.888Z","repository":{"id":139298015,"uuid":"78231870","full_name":"mars/heroku-nextjs-custom-server-express","owner":"mars","description":"Deploy Next.js server-side React apps using a custom Express server to Heroku","archived":false,"fork":false,"pushed_at":"2019-03-29T17:30:43.000Z","size":87,"stargazers_count":95,"open_issues_count":1,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T14:51:12.268Z","etag":null,"topics":["expressjs","heroku","nextjs","react","universal-app"],"latest_commit_sha":null,"homepage":"https://nextjs.herokuapp.com","language":"JavaScript","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/mars.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-01-06T19:14:30.000Z","updated_at":"2024-11-28T00:04:45.000Z","dependencies_parsed_at":"2024-01-08T08:05:52.940Z","dependency_job_id":null,"html_url":"https://github.com/mars/heroku-nextjs-custom-server-express","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fheroku-nextjs-custom-server-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fheroku-nextjs-custom-server-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fheroku-nextjs-custom-server-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fheroku-nextjs-custom-server-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mars","download_url":"https://codeload.github.com/mars/heroku-nextjs-custom-server-express/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248995101,"owners_count":21195497,"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":["expressjs","heroku","nextjs","react","universal-app"],"created_at":"2024-08-04T01:01:43.187Z","updated_at":"2025-04-15T02:36:55.611Z","avatar_url":"https://github.com/mars.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"\n# Next.js w/ Custom Express Server example for Heroku\n\n## How to use\n\n```bash\ngit clone https://github.com/mars/heroku-nextjs-custom-server-express\ncd heroku-nextjs-custom-server-express\n```\n\nInstall it and run:\n\n```bash\nnpm install\nnpm run dev\n```\n\nThen, visit [http://localhost:3000/](http://localhost:3000/) in your web browser.\n\nDeploy it to the cloud with [Heroku](https://www.heroku.com):\n\n⚠️ *Requires installing [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli)*\n\n```bash\nheroku create\ngit add .\ngit commit -m 'Next.js app on Heroku'\ngit push heroku master\n```\n\nHeroku auto-detects that this is a Node.js app, and then executes:\n\n* `npm install`\n* `npm run build`\n* and then launches the app `NODE_ENV=production npm start`.\n\n👉 An example deployment of master is running at [https://nextjs-server.herokuapp.com/](https://nextjs-server.herokuapp.com/).\n\n## The idea behind the example\n\n*A version of [Next's example/custom-server-express](https://github.com/zeit/next.js/tree/master/examples/custom-server-express) revised to [deploy to Heroku](https://github.com/mars/heroku-nextjs).*\n\nMost of the times the default Next server will be enough but sometimes you want to run your own server to customize routes or other kind of the app behavior. Next provides a [Custom server and routing](https://github.com/zeit/next.js#custom-server-and-routing) so you can customize as much as you want.\n\nBecause the Next.js server is just a node.js module you can combine it with any other part of the node.js ecosystem. in this case we are using express to build a custom router on top of Next.\n\nThe example shows a server that serves the component living in `pages/a.js` when the route `/b` is requested and `pages/b.js` when the route `/a` is accessed. This is obviously a non-standard routing strategy. You can see how this custom routing is being made inside `server.js`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmars%2Fheroku-nextjs-custom-server-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmars%2Fheroku-nextjs-custom-server-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmars%2Fheroku-nextjs-custom-server-express/lists"}