addTvb
addTvb

Reputation: 55

Can I load 1 component on a page using SSG and another using SSR, in Next,js?

That is, can I statically generate a header and main content using SSR

Upvotes: 3

Views: 1358

Answers (1)

Zakaria Benali
Zakaria Benali

Reputation: 318

Unfortunately, you can't achieve such a thing with pure next.js.

As stated in their docs for SSR:

getServerSideProps can only be exported from a page. You can’t export it from non-page files.

Same goes for SSG:

getStaticProps can only be exported from a page. You cannot export it from non-page files, _app, _document, or _error.

You can only use next.js data-fetching on page level.

Upvotes: 5

Related Questions