nuxt-users
Version:
A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools
23 lines (22 loc) • 638 B
TypeScript
import type { UserWithoutPassword } from 'nuxt-users/utils';
/**
* Server-side composable for authentication utilities
*
* @example
* ```typescript
* // server/api/protected-route.get.ts
* export default defineEventHandler(async (event) => {
* const { getCurrentUser } = useServerAuth()
* const user = await getCurrentUser(event)
*
* if (!user) {
* throw createError({ statusCode: 401, statusMessage: 'Unauthorized' })
* }
*
* return { message: `Hello ${user.name}!` }
* })
* ```
*/
export declare const useServerAuth: () => {
getCurrentUser: (event: unknown) => Promise<UserWithoutPassword | null>;
};