ssr with getserversideprops nextjs

ssr with getserversideprops nextjs

If you export an async function called getServerSideProps from a page, Next.js will pre-render this page on each request using the data returned by getServerSideProps.

Copy Snippet
export async function getServerSideProps(context) {
  return {
    props: {}, // will be passed to the page component as props
  }
}

// The context parameter is an object containing the following keys:

// params: If this page uses a dynamic route, params contains the route parameters. If the page name is [id].js , then params will look like { id: ... }.

// req: The HTTP IncomingMessage object.

// res: The HTTP response object.

// query: The query string.

// preview: preview is true if the page is in the preview mode and false otherwise.

// previewData: The preview data set by setPreviewData.