How to create static pages using T3 stack?
Title, for now I need to create only SOME static pages, but I have no idea how to set them up with next, what I need to add to make them static? Thanks!
8 Replies
if you don't use any react stuff in your page, next will automatically make it a static page
if you want to fetch data you will need to use getStaticProps
Also good way to check how nextjs renders is to build your app to see what pages are static and what runs on server (it shows it after build)
@rocawear but I want to create react components etc
Not only plain html
if they have any interactivity they can't be static pages
you can still create components
just can't use useState, etc
Nextjs with SSG have opinion for revalidation. Can that be used to add interactivity for pages? Or react query with hydration? I have no experience but wanted to give my 5cents for the topic, also would like to know the answer. Atm not on computer so cant test by myself
And what about the interactivity between pages?
The navigator
You are already doing it, next makes pages automatically static if you are already putting the content by hand in the codebase. You can use getStaticProps to have the content be created for you at build time too if you like.
that willl work
to use react query the react dom will have to be loaded
so yes not a static page
only way to load data is through getStaticProps