Skip to content

Only update useSupabaseUser state if user has actually changed #568

@aaaaahaaaaa

Description

@aaaaahaaaaa

Currently, the useSupabaseUser composable is updating the state on every single page start. This means that watching the ref returned by the composable, as shown in through out the doc, will always fire needlessly:

const user = useSupabaseUser()
watch(user, async (newUser) => {
 // always fires on page change
}

Which makes implementing any kind of other states (e.g. stores) based on that composable unpractical as it would be very completely unoptimal (e.g. firing database calls on every page load).

Therefore, the composable should only update the state if the user actually changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions