Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next.js API is back-end?

I know Next.js is front-end but when i used API of next.js it can response and can manage route or anything about back-end can do. Then i want to know "Next.js api is back-end ?"

like image 225
Loga Thrim Avatar asked Jul 02 '20 07:07

Loga Thrim


1 Answers

Dynamic Routing has two folders pages or api. To stay on the front-end or client-side put your JavaScript / React DOM code in pages. The back-end or server-side of Next.js is with the api folder. The api JavaScript code is not executed in the browser but with Node.js so this is not safe for static page generation. When Next.js is hosted in the cloud with Vercel then your server-side JS will render, but on Netlify or other static hosts the api folder will be ignored or throw errors. It's like running Express.js code in the browser the JIT rendered will fail

like image 96
danactive Avatar answered Sep 22 '22 15:09

danactive