NuxtN
Nuxt4mo ago
12 replies
Pranoy

How to export types of an nuxt plugin?

So i'm using the better-auth, and for the client part, i created a nuxt plugin like this:
import { createAuthClient } from "better-auth/vue";
export default defineNuxtPlugin(() => {
  const authClient = createAuthClient({});

  return {
    provide: {
      authClient,
    },
  };
});


But how can i export/infer some types from authClient ? like if i just created this client in a lib/auth-client.ts i can easily do like this:

import { createAuthClient } from "better-auth/vue";

export const authClient = createAuthClient({});

export type AuthSession = (typeof authClient.$Infer.Session)["session"];
export type AuthUser = (typeof authClient.$Infer.Session)["user"];


But with plugin i didn't found a way to do the same thing
Was this page helpful?