streaming, markdown, model selecting, and lots more
This commit is contained in:
+22
-10
@@ -1,10 +1,22 @@
|
||||
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()
|
||||
})
|
||||
}
|
||||
})
|
||||
export default defineNuxtPlugin({
|
||||
name: 'better-auth-triplit',
|
||||
enforce: 'pre',
|
||||
async setup(nuxtApp) {
|
||||
if (import.meta.client) {
|
||||
const triplit = useTriplitClient();
|
||||
const { session, fetchSession } = useAuth();
|
||||
|
||||
nuxtApp.hook('app:mounted', async () => {
|
||||
if (!session.value) {
|
||||
await fetchSession();
|
||||
}
|
||||
|
||||
if (!session.value) return;
|
||||
|
||||
if ('startSession' in triplit) {
|
||||
await triplit.startSession(session.value.token);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user