{"id":28336826,"url":"https://github.com/ross-u/deploy-json-server-to-heroku","last_synced_at":"2025-09-13T08:07:32.495Z","repository":{"id":42930066,"uuid":"240324771","full_name":"ross-u/deploy-json-server-to-heroku","owner":"ross-u","description":"Create your own server/API in minutes. Ready to deploy json-server configuration with a beginner friendly guide.","archived":false,"fork":false,"pushed_at":"2022-12-12T01:50:54.000Z","size":3070,"stargazers_count":8,"open_issues_count":10,"forks_count":19,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T11:40:00.515Z","etag":null,"topics":["api","beginner","guide","heroku","heroku-cli","heroku-deployment","javascript","json","json-server","node","nodejs","server","simple","tutorial"],"latest_commit_sha":null,"homepage":"","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/ross-u.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":"2020-02-13T17:51:16.000Z","updated_at":"2025-01-07T19:04:46.000Z","dependencies_parsed_at":"2023-01-27T10:15:50.750Z","dependency_job_id":null,"html_url":"https://github.com/ross-u/deploy-json-server-to-heroku","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ross-u/deploy-json-server-to-heroku","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ross-u%2Fdeploy-json-server-to-heroku","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ross-u%2Fdeploy-json-server-to-heroku/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ross-u%2Fdeploy-json-server-to-heroku/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ross-u%2Fdeploy-json-server-to-heroku/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ross-u","download_url":"https://codeload.github.com/ross-u/deploy-json-server-to-heroku/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ross-u%2Fdeploy-json-server-to-heroku/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260834992,"owners_count":23070205,"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","beginner","guide","heroku","heroku-cli","heroku-deployment","javascript","json","json-server","node","nodejs","server","simple","tutorial"],"created_at":"2025-05-26T23:15:59.241Z","updated_at":"2025-09-04T04:09:20.071Z","avatar_url":"https://github.com/ross-u.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deploying a `json-server` app to Heroku\n\n\n\n\u003cbr\u003e\n\n\n\n## `json-server` package\n\n\nTo speed up the initial development of the web apps and creation of the initial MVP, developers sometimes use packages/libraries that enable easy creation of API's without the need to code the entire server structure.\n\nOne of such tools is a `npm` package called [`json-server`](https://www.npmjs.com/package/json-server).\n\n[`json-server`](https://www.npmjs.com/package/json-server) is a package that can be easily installed and run on the cloud hosting solution and it only requires a properly formated `.json` file.\n\n\n\n\u003cbr\u003e\n\n\n\n## Getting Started\n\n\n\n\u003cbr\u003e\n\n\n\nThis repository includes the complete setup needed for deploying a `json-server` app to Heroku.\n\n##### Steps:\n\n1. [Fork and Clone the repository.](#fork-and-clone)\n2. [Add the custom `db.json` file.](#add-custom-db-json)\n3. [Deploy `json-server` app to Heroku.](#deploy-to-heroku)\n\n\n\n\u003cbr\u003e\n\n\n\n\u003ca name=\"fork-and-clone\"\u003e\u003c/a\u003e\n\n##  Fork and clone the repository \n\n\n\nBefore adding a custom `db.json` file you should **Fork** this repo to your user account. \n\nOnce done **Clone** that repo to your local machine by using the link from your own repository.\n\n\n\n\u003cbr\u003e\n\n\n\n\u003ca name=\"add-custom-db-json\"\u003e\u003c/a\u003e\n\n## Add the custom `db.json` file\n\n\u003cbr\u003e\n\n\n\n#### `db.json` file\n\n\n\nOnce run, `json-server` loads the provided file `db.json` and uses it as the database/storage,  using the first level property names of the `db.json` object as the actual server endpoints.\n\n\n\n\u003cbr\u003e\n\n\n\n`json-server` will make these first level properties into server endpoints `domain.com/posts`, `domain.com/comments`, `domain.com/profile` .\n\n\n\n\u003cbr\u003e\n\n\n\nGive it a try with the deployed server example. \n\nThe below url's belong to the server deployed with the example code in this repo, using the `db.json` file that you will find in this repo.\n\n\n\n Open the below links in your browser or make `GET` request using [Postman](https://www.postman.com/), to see how `db.json` is transformed into server endpoints:\n\n\u003cbr\u003e\n\n\n\n##### [https://json-server-ih.herokuapp.com](https://json-server-ih.herokuapp.com/)\n\n##### https://json-server-ih.herokuapp.com/posts\n\n##### https://json-server-ih.herokuapp.com/comments\n\n##### https://json-server-ih.herokuapp.com/profiles\n\n\u003chr\u003e\n\n##### https://json-server-ih.herokuapp.com/posts/1\n\n##### https://json-server-ih.herokuapp.com/profiles/5\n\n\n\n\u003cbr\u003e\n\n\n\n#### Creating custom endpoints\n\nIn order to create custom endpoints on your server, you need to include them in the `db.json` file.\n\n\n\nYou can replace the existing `db.json` file with your own file in order to get custom endpoints and data that will be served. \n\nOnly rule that should be observed is that file must be named `db.json` and be placed in the root directory of the project, as it is in this starter code example.\n\n\n\n\u003cbr\u003e\n\n\n\n\u003ca name=\"deploy-to-heroku\"\u003e\u003c/a\u003e \n\n## Deploy `json-server` to Heroku\n\n\n\n#### Sign up for Heroku\n\nIf you don't have a Heroku account you should [Sign up / create Heroku account](https://signup.heroku.com/). \n\n\n\n\u003cbr\u003e\n\n#### Install the Heroku CLI\n\nCheck if you have the Heroku CLI installed.\n\nTo [verify your Heroku CLI installation](https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version), use the `heroku --version` command:\n\n\n\n```bash\nheroku --version\n\n# If already installed you should get something like this:\nheroku/7.0.0 (darwin-x64) node-v8.0.0 \n```\n\n\n\u003cbr\u003e\n\nIf you didn't get the version of Heroku printed in your terminal after executing command `heroku --version` it means that you don't have the Heroku CLI installed yet on your system.\n\nIn that case you should [downolad Heroku CLI here](https://devcenter.heroku.com/articles/heroku-cli#download-and-install) and install it, before the next step.\n\n\n\n\u003cbr\u003e\n\n\n\n#### Login to Heroku\n\nAfter you ensure that Heroku CLI is installed, run the `heroku login` command. \n\nYou’ll be prompted to enter any key to go to your web browser to complete login. The CLI will then log you in automatically.\n\n```bash\nheroku login\n```\n\n\n\n\u003cbr\u003e\n\n\n\n#### Create a new Heroku app\n\nBefore running the below commands, using the terminal navigate to the root directory of the cloned server project.\n\nTo create a new Heroku app/project run the command (in order for your app to have a custom name, change the `name-of-your-server-app` part to include name that you want) from the root directory of the cloned project:\n\n```bash\nheroku create name-of-your-server-app\n```\n\n\n\n\u003cbr\u003e\n\n\n\nRunning the above command will create the new Heroku/app project and also add new `git remote` to the current project, pointing to Heroku which we will use to push the code from our machine to Heroku.\n\nTo check the newly added `git remote` you run the command:\n\n```bash\ngit remote -v\n```\n\n\n\n\n\n\u003cbr\u003e\n\n\n\n#### Push to Heroku\n\nThis is the final step, which pushes our local code to Heroku dyno which will instantiate the new server and run it automatically.\n\nCommit all the updates and then push to heroku by running the command:\n\n```bash\ngit push heroku master\n```\n\n\n\n\u003cbr\u003e\n\n\n\n#### Done! ✅ \n\nOnce done you will be able to make the HTTP requests using the URL of your Heroku app and the endpoints created from the `db.json`. \n\nVisit your Heroku dashboard by visiting https://dashboard.heroku.com/apps to see the newly created (and running) `json-server` app and the server URL. 😊 \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fross-u%2Fdeploy-json-server-to-heroku","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fross-u%2Fdeploy-json-server-to-heroku","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fross-u%2Fdeploy-json-server-to-heroku/lists"}