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

Feedback for “Usage with Next.js” #558

Open
AnilAragala opened this issue Jan 3, 2024 · 1 comment
Open

Feedback for “Usage with Next.js” #558

AnilAragala opened this issue Jan 3, 2024 · 1 comment

Comments

@AnilAragala
Copy link

Hi Team,
I am using SWR to cache the api data to use entire session until page get reload or refresh. I want to hit the api only once when the user visits the page first time and don't want to hit again when user revisit the page.

Here is the scenario:

  1. User will login to the home page and visits the blog page. blog page has the api functionality to catch the data and use the entire session until page get refresh.
  2. And the user go back to home page and revisit the blog page i need to use cached data without hitting a api call.

Is there any solution for this scenario. I tried all the options like revalidateOnMount, revalidateOnFocus and mutate and etc. But, no luck.

Your help is highly appreciated.

Thank you

@koba04
Copy link
Collaborator

koba04 commented Jan 5, 2024

@AnilAragala Doesn't useSWRImmutable fit in your case?
https://swr.vercel.app/docs/revalidation.en-US#disable-automatic-revalidations

If so, could you create a CodeSandbox project to reproduce it?

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

No branches or pull requests

2 participants