Building an API in minutes using NextJS

Make sure you do it while you read. Also, Share the good work you do

Wondering every day to start learning about backend development and delaying it every single day. Okay, this is not a place to learn backend development, But yeah we can start with creating an API. Let's do it.

Steps to start

  1. Create a NextJS app by using npx create-next-app@latest project-name to create a project on a new folder or npx create-next-app@latest . to create a project in the current folder
  2. If you have created the project in a different folder following the first approach, Then checkout to your project name folder by using cd project-name
  3. Check your git log status by using git log. You will be able to see your first commit automatically been created
  4. Now, Go to the pages folder. All the front end and the back end lie in this folder. Now under the API folder, Open the hello.js file
  5. Run the project using yarn run dev or npm run dev
  6. In the hello.js file, We can change our name from John Doe to your name and go to the browser page localhost:3000 and refresh it. We can see the name has changed from John Doe to your name

That's it. This is how you build a simple API. I know it's not a lot, But, That is it. Hopefully, you followed it right. If not, Go through the Eddie Jaoude video