Statically render in production but dynamically render in dev?
Answered
Narrow-barred Spanish mackerel posted this in #help-forum
Narrow-barred Spanish mackerelOP
I'm building a site with a strapi backend that will not change very much so in production i want to statically render everything, but i want to dynamically render while developing to make things faster.
right now i'm just putting in and taking out noStore()s manually which is not that great 😓 . Is there a good way to do this?
right now i'm just putting in and taking out noStore()s manually which is not that great 😓 . Is there a good way to do this?
8 Replies
@Narrow-barred Spanish mackerel I'm building a site with a strapi backend that will not change very much so in production i want to statically render everything, but i want to dynamically render while developing to make things faster.
right now i'm just putting in and taking out noStore()s manually which is not that great 😓 . Is there a good way to do this?
dev mode is always dynamically rendered, you need not do anything
@joulev dev mode is always dynamically rendered, you need not do anything
Narrow-barred Spanish mackerelOP
maybe I'm confusing concepts then? If I start the dev server and then make changes to my database it doesn't show up when i refresh the page until I restart the server, unless I add noStore() to all my fetch functions.
from this: https://nextjs.org/learn/dashboard-app/static-and-dynamic-rendering
i thought that was because of static rendering.
from this: https://nextjs.org/learn/dashboard-app/static-and-dynamic-rendering
i thought that was because of static rendering.
not using a database, but use a different data source e.g. reading and writing to a local file for ease of set up
@joulev make a reproduction repository
Narrow-barred Spanish mackerelOP
https://github.com/noah-evans/nextjs-dev-server-not-updating
this fetches the current time and displays it, but it won't update when you refresh unless you uncomment noStore() in app/data.js
this fetches the current time and displays it, but it won't update when you refresh unless you uncomment noStore() in app/data.js
@Narrow-barred Spanish mackerel https://github.com/noah-evans/nextjs-dev-server-not-updating
this fetches the current time and displays it, but it won't update when you refresh unless you uncomment noStore() in app/data.js
Interesting. Looks like a bug yes, could you file a bug report?
Answer
hard refresh to clear the data cache