Too Lazy to Make a Full Backend? db-json

John Zhang
2 min readDec 8, 2020

As a Reactjs full stack developer, I’ve made my decent share of back-end databases. However sometimes I just want to work on the front end so I use a nifty npm package called db-json. Assuming you already have npm already installed, it all starts with entering this into your terminal.

npm i db-json

After allowing this to download create a new file called “db.json” in the project folder. At this point you would enter information into this file like you’d expect to see on an API.

Which would equate to:

The “streamers” grouping at the top making the “streamers” in the localhost url. Additionally you can manually change the port the api to be addressed to by going to the package.json file

And adding

json-server --watch db.json -p 3001

to the scripts start line, so from

to this:

With the 3001 telling the api to load up on localhost:3001/

While I believe nothing really beats an actual properly setup back-end, sometimes it might just not be necessary. Maybe there is one on the way but isn’t ready yet, maybe you just want to work on the front end first or maybe like the title says, you’re just too lazy to make one at the moment. Either way I find db-json to be an immensely helpful package.

--

--