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

Are multiple calls to the same Supabase operation cached across pages and components? #333

Open
btahir opened this issue Apr 24, 2024 · 0 comments

Comments

@btahir
Copy link

btahir commented Apr 24, 2024

Hi - basic App Router question but I'm trying to understand if calling the same Supabase operation gets automatically cached in app router similar to fetch?

I need to fetch the User on multiple pages and am calling the same function again rather than trying to pass it in Context like the good (bad) ol' useUser days.

export async function getUser() {
  const supabase = createClient()
  const {
    data: { user },
  } = await supabase.auth.getUser()
  return user
}

I noticed you did the same on login and pricing pages. Just want to confirm this pattern is ok and we can re-use DB read operations across pages and components without worrying about performance hits?

Thanks!
Love this starter and appreciate the app router upgrade. :)

UPDATE

I can confirm that using getUser causes the function to be called again and again at least across routes. Maybe that's ok though since you want the latest user state? Still feels very sluggish when i first click on a link and have to wait a few secondd for page to route.

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

1 participant