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

Using Tina + Next.js without getInitialProps() #473

Closed
sorleone opened this issue Nov 16, 2019 · 1 comment
Closed

Using Tina + Next.js without getInitialProps() #473

sorleone opened this issue Nov 16, 2019 · 1 comment
Labels
question Further information is requested

Comments

@sorleone
Copy link

As you can read here:

https://nextjs.org/docs#automatic-static-optimization

the presence in a page/component of getInitialProps() disables the automatic static optimization. Having that optimization helps a lot to improve performance.

In the official Tina tutorial for Next.js, I can't find how to pull the required data to pre-render a page (in case it's a static one), at build time. Is this already happening or not? In other words, is Tina using getInitialProps() to pull the data at runtime, thus turning Next.js in a dynamic-only framework?

https://tinacms.org/docs/nextjs/creating-forms

@ncphillips ncphillips added the question Further information is requested label Nov 18, 2019
@dwalkr
Copy link
Contributor

dwalkr commented Nov 21, 2019

Thanks for bringing this up @sorleone - I'm still getting the hang of Next and figuring out the best way to do things. You are correct that the current implementation demonstrated in Tina's Next.js tutorial does not create a static site, but in fact requires a node server to prepare the markdown content upon request. I know this isn't ideal, but for what it's worth, the tutorials on the Tina site are primarily geared toward showing you how to use Tina and aim to spend a minimum amount of time on project setup.

It's true that getInitialProps disables automatic static optimization, but you can still manually tell Next how to export static pages for your site by creating an exportPathMap() function in next.config.js. NextJS has a tutorial on how to use exportPathMap that might help you along here.

I'm going to close this issue, with two notes:

  1. Issues related to the documentation or content on tinacms.org would better fit in the tinacms-site repo, so please feel free to post any further concerns there.
  2. After researching this issue, I plan to write a blog post on how to use exportPathMap to statically generate pages. This post will be published to tinacms.org, so keep an eye out for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants