2

I am trying to understand NextJs. I understand that nextJs is a React Based framework. I also understand that NextJs has the functionality of creating a backend using nodeJS. Is this backend made up of serverless functions?

1 Answer 1

3

NextJS is a front-end framework at its core. The Node.js backend it creates is in support of its ability to perform SSR/ISR data fetching.

When you say

is this backend made up of serverless functions?

I think you are referring to the NextJS pages/api directory, which provides an easy way to create API endpoints. While you can choose to treat these as serverless functions (Vercel, the creators of NextJS, provide an easy way to do this), you can also choose to have these API endpoints served any way you want, like by an Express server for example. To do this you would have code in your pages/api/<api-route-name>.js file that fetches data from another server. You can choose also to not use the pages/api directory at all and make your server calls how you normally would in a React app.

You may also opt to customize NextJS routing/server behavior completely by using a custom server. While NextJS does provide an opinionated structure, you can really do whatever you want on the backend.

Sign up to request clarification or add additional context in comments.

2 Comments

nextjs is a full stack framework. Almost all of the code you write in next runs on the backend, calling it a front end framework is not really accurate
Yes Next.js is a full-stack framework, but backend doesn't mean "it passes through a server" it means the part not visible to the client. In the answer I am trying to highlight the "frontend" vs "backend" parts of someone's Next.js app. This answer was also written before the app router and server components where the default (core) method of data-fetching was client-side. Feel free to update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.