Skip to content
Discussion options

You must be logged in to vote

There currently isn't a way to programmatically revalidate pages via something like a webhook or API. In the meantime, one option would be to serve a static loading state from the server followed by client-side rendering.

  1. Your Next.js app renders loading state from the server, so the first paint is fast
  2. Then, you make an API call using a library like SWR
  3. SWR allows you to reduce the number of calls to your database by only fetching when the content is stale
  4. A user edits an entry in the database
  5. You can manually update the SWR cache instantly, and then refetch in the background

Example of an edit modal which mutates an SWR cache: https://github.com/leerob/fastfeedback/blob/master/compone…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@leerob
Comment options

Answer selected by MehediH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants