How to generate HTML on request time instead of build time in next js 14

77 Views Asked by At

I want to achieve SSR functionality in next js 14.In next js 12 there was get server side props but in latest next js version get server side props is removed.How can i achieve get server side props functionality in next js 14

1

There are 1 best solutions below

0
Llama On

Next.js 14 provides two types of routers, the app router and the pages router. The rendering in both environments differs, in the way you have noticed. The app router, identified by the app directory, uses client and server components. Here you can run server side code in React components instead of pages. The pages router, identified by the pages directory, uses server-side rendering, client-side rendering and static side generation on page level. Here you have to opt-in into one of these rendering techniques for each page.

Just because you are using Next.js 14, doesn't mean you cannot use the pages router, but the app router is promoted as the way to go, by Next.js. You can read up on their rendering techniques here:

pages router app router