Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Next.js with spring-boot as back-end server?

How can I setup a project using Next.js and springboot. I tried to read next.js documentations, all of them point to other backend technologies, none of them showing springboot setup. If someone can guide me, or provide me some documentation of how to use those both frameworks in one project, it will be of a great help.

Developing with springboot or react, I am fine with them, I don't have any difficult.

like image 230
Mugirase Emmanuel Avatar asked Apr 22 '19 09:04

Mugirase Emmanuel


1 Answers

Springboot is another backend server that stand alone outside NextJS project. The way to make it works between NextJS project and springboot is by serving springboot as a RESTful API, then you call springboot's API from NextJS.

I never touch springboot before, but here is the reference how to serve springboot as a backend API: https://dzone.com/articles/ext-js-4-spring-mvc-crud.

And this is one example of how do you fetch data from front-end using NextJS: https://github.com/zeit/next.js/blob/canary/examples/data-fetch/pages/index.js.

There are many method on how do you fetch data from front-end, some of the options include these npm dependencies:

  1. HTTP - Standard Library
  2. Request
  3. Axios
  4. SuperAgent
  5. Got
like image 104
Darryl RN Avatar answered Nov 15 '22 07:11

Darryl RN