feat(frontend): Use betterAuth implementation from nuxthub-better-auth project
This commit is contained in:
12
legalconsenthub/plugins/auth.client.ts
Normal file
12
legalconsenthub/plugins/auth.client.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copied from https://github.com/atinux/nuxthub-better-auth
|
||||
|
||||
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
if (!nuxtApp.payload.serverRendered) {
|
||||
await useAuth().fetchSession()
|
||||
} else if (Boolean(nuxtApp.payload.prerenderedAt) || Boolean(nuxtApp.payload.isCached)) {
|
||||
// To avoid hydration mismatch
|
||||
nuxtApp.hook('app:mounted', async () => {
|
||||
await useAuth().fetchSession()
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user