chen
chen

Reputation: 4500

Can I host my next.js on AWS lambda edge and have a separate API server?

Next.js is about server side rendering. Therefore have the render server (rendering the HTML) along with the API server seems to be a natural choice— it probably makes the rendering time much lower than having a separate API server (service)

That’s what I am thinking of theoretically.

But I would like to know if next.js applications are typically deployed in this way (a node server host both the api service and the next.js app).

Or does it make sense to have one service host the next.js app and another service host the rest api endpoints. e.g

  1. Next.js is hosted on lambda edge
  2. Api service hosted on api-gateway (+ lambda + dynamodb)

Upvotes: 3

Views: 754

Answers (1)

Raj
Raj

Reputation: 3908

Lambda@Edge functions can only operate for a maximum of 5 seconds for viewer request functions and 30 seconds for origin request functions, so it's probably not practical to have the entire Next.js app on Lambda@Edge.

You could have individual portions of the app's logic on Lambda@Edge, but you also need to think about total package size because there are restrictions there as well.

Upvotes: 1

Related Questions