简体   繁体   中英

Why Next.js API?

Im starting with Next and I'm kind of confused about how it works the SSR and the API. When should I use the API folder in pages instead of having my own server with a database? Does Next server for SSR will have any conflict if I had my server in Node for example?

The point is to provide a simple, scalable alternative to running your own server.

When you deploy API routes via Vercel, it will provision AWS Lambda functions on the backend to form your API.

These functions are sort of like individual snips of code that get run on demand when you have traffic.

You're right in the sense that there isn't too much difference. Just an alternative way to deploy your API. The main purpose is to make it easy and reduce the management associated with running a server.

For most use cases, it should work well but please note it doesn't have support for Websockets.

You're free to use API routes, or your own server. It doesn't matter and won't impact on the SSR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM