← Back to all tutorials
React TutorialEpisode 16

Using JSON Server

Set up a fake REST API using JSON Server for local development and testing.

JSON Server creates a full fake REST API from a JSON file — perfect for development.

Setup

npx json-server --watch data/db.json --port 8000

db.json

{
  "blogs": [
    { "id": 1, "title": "My Blog", "body": "Content...", "author": "Mario" },
    { "id": 2, "title": "React Tips", "body": "More...", "author": "Yoshi" }
  ]
}

Auto-Generated Endpoints

  • GET /blogs — All blogs
  • GET /blogs/1 — Single blog
  • POST /blogs — Create blog
  • DELETE /blogs/1 — Delete blog