Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to build a site with an AMP site with Next.js that pulls data from a headless CMS? #7492

Closed
kompounder opened this issue Jun 4, 2019 · 5 comments

Comments

@kompounder
Copy link

  1. I am looking to build a website with full AMP support, that pulls all of its data from a headless CMS such as Contentful or Prismic. I also recently learned that Next.js announced support for AMP. Is it feasible to build this with Next.js?

  2. Regarding Next.js support for static exports, if a part of the site should not be static (e.g. for member only content, etc), is it possible for me to build this in a hybrid way - i.e. most of the website using next.js static export, and the rest dynamic?

Thank you.

@ijjk
Copy link
Member

ijjk commented Jun 4, 2019

  1. Yes, this is feasible. You can use getInitialProps to load data from your CMS and render it with AMP.
  2. This is also possible but currently experimental see the RFC here. You can test it out by setting experimental.autoExport to true on the latest canary of Next.js next@canary. This will automatically export pages without getInitialProps as HTML

@kompounder
Copy link
Author

Thank you @ijjk. On #2, if all of the website's content is served from a CMS (so I would have to use getInitialProps for every page?), but a part of the website is best kept static (e.g. public blog posts) while others are dynamic (e.g. member only content), then are there any workarounds today to implement this in hybrid mode? It seems that the autoExport feature would detect getInitialProps on every page in this case.

@ijjk
Copy link
Member

ijjk commented Jun 4, 2019

It is not currently supported to have a page auto exported when it has getInitialProps. We might add a way to opt-in to this after we investigate it further but it is still an experimental feature for now. A workaround you could do is to use the next export command with an exportPathMap to only exports the pages you are wanting exported

@timneutkens
Copy link
Member

I'm going to close this issue as it doesn't follow the issue template.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants