When NextJS is deployed in Vercel, does the API end-points get deployed to serverless? - next.js

Completely new to Vercel and NextJS here. I can see you can easily add REST API end-points to NextJS using the api folder. I also played around with deploying the server to Vercel and that was very easy. I am just wondering if the api end-points are deployed to some serverless infra. In AWS Lambda, serverless end-points had restrictions as to how long a single lambda execution can take. Is NextJS end-points also under the similar restrictions in Vercel deployment?

Related

Next.js change from edge function to serverless functions on Netlify

When deploying a Next.js project to Netlify, API routes are deployed as Edge Functions by default.
How can I switch so they are deployed as serverless functions?
I've looked through all the docs I can't find anything about this.
As of February 2023, that is untrue. Next.js API routes are deployed using Netlify Functions and not Netlify Edge Functions.
Source: https://github.com/netlify/next-runtime#generated-functions
Quoting:
The Next.js Runtime works by generating three Netlify functions that handle requests that haven't been pre-rendered. These are ___netlify-handler (for SSR and API routes)...

nextJS pages/api vs vercel serverless functions

I want to create a backend for my NextJs application which is deployed by Vercel.
I need to create a server for my app and other "back-office" computation the application needs (application related but not directly served to the application. e.g update an existing M.L model, analytics etc )
Utilizing my technology stack I got two options :
NextsJS - pages/api
Vercel Serverless Functions - which also state in some cases the pages/api but you can also use other programing languages and the /api folder
Questions :
What's the difference between them?
Which is Vercel and which is "native NextJS"?
When should I use each?

Initializing Firebase Functions Emulator For Correct Project

I am developing a project with Firebase backend, utilising Firebase Functions. I actually two projects: myProject and myProject-test (used for deployment testing).
When submitting API calls, my (React) front-end is configured to call the myProject-test URL when running in local development, and only direct the calls to myProject when deployed on PROD.
The problem I am facing is that when I start my cloud functions emulator using firebase emulators:start, my cloud functions get started on the localhost:5001/myProject/... url instead of localhost:5001/myProject-test/..., and hence the API calls from my local development instance never arrive.
How can I control for which project the emulators start?
This is what the firebase use command is for. Read the documentation on managing aliases. You can run the command firebase use PROJECT_ID|ALIAS to set the current project or alias that is currently use use for the emulator or other commands.

Netlify CMS and NextJS: Do I NEED to use Netlify to deploy, or can I use Vercel?

Right now I am hosting my NextJS application using Vercel, and am attempting to add a blog via Netlify CMS. It seems like all the documentation I find online points to having to use Netlify. Is there any reason not to use Netlify instead of Vercel?
If you are thinking of using Netlify CMS, regardless of the frontend you are using, it would be smoother process to deploy it to Netlify, compared to Vercel. I've heard some people had some issues and encountered more steps todo deploying such app to Vercel.

nextjs on vercel / zeit writing to disk fs.writeFile

I am using a custom server with nextjs to inject some serverSideProps / getInitialProps into files. What I am doing is having something on the server update a json file every minute or so and then the getServerSideProps/getInitialProps functions read the json file from disk to populate data quickly (without having to do a network request for data).
Everything works great in localhost and when doing a build/running the build locally. In production / after deploying to vercel i get the error: Internal Server Error when trying to open a page. Vercel offers build logs but not any logs for the running custom server.
Is this likely a problem to do with unable to write to disk in the vm's that vercel uses to deploy apps?
Is there an example out there of how I can read/write to disk with a custom server in nextjs for this purpose?
Vercel is a serverless platform and doesn't support a custom server.
If possible, you can migrate away from the custom server (with API routes) or consider other hosting options.
Next.js Deployment

Resources