From ab0d9cc309ee9ffa3ff43fa81ee5443e25416ee7 Mon Sep 17 00:00:00 2001
From: Bereket Engida <86073083+Bekacru@users.noreply.github.com>
Date: Thu, 17 Oct 2024 22:14:56 +0300
Subject: [PATCH] feat: support useSession ssr for nuxt (#209)
---
docs/content/docs/integrations/nuxt.mdx | 28 ++++++++++++++----
examples/nuxt-example/lib/auth-client.ts | 4 +--
examples/nuxt-example/pages/dashboard.vue | 13 ++++----
examples/nuxt-example/pages/index.vue | 7 +++--
package.json | 2 +-
packages/better-auth/src/client/vue.ts | 36 ++++++++++++++++++++++-
6 files changed, 71 insertions(+), 19 deletions(-)
diff --git a/docs/content/docs/integrations/nuxt.mdx b/docs/content/docs/integrations/nuxt.mdx
index 5df2192a..90074a39 100644
--- a/docs/content/docs/integrations/nuxt.mdx
+++ b/docs/content/docs/integrations/nuxt.mdx
@@ -35,20 +35,20 @@ Create a client instance. You can name the file anything you want. Here we are c
```ts title="client.ts"
import { createAuthClient } from "better-auth/vue" // make sure to import from better-auth/vue
-export const client = createAuthClient({
+export const authClient = createAuthClient({
//you can pass client configuration here
})
```
Once you have created the client, you can use it to sign up, sign in, and perform other actions.
-Some of the actinos are reactive. The client use [nano-store](https://github.com/nanostores/nanostores) to store the state and re-render the components when the state changes.
+Some of the actinos are reactive.
### Example usage
```vue title="index.vue"
@@ -66,4 +66,22 @@ const session = client.useSession()
-```
\ No newline at end of file
+```
+
+### SSR Usage
+
+If you are using Nuxt with SSR, you can use the `useSession` function in the `setup` function of your page component and pass `useFetch` to make it work with SSR.
+
+```vue title="index.vue"
+
+
+
+