Getting Started

Introduction

Welcome to Nuxt Auth.

This module covers the basics of authentication in Nuxt.

It provides a simple yet flexible way to authenticate users in your Nuxt app.

server/api/profile.get.ts
export default defineEventHandler((event) => {
  // Throw 401 Unauthorized if user is not authenticated
  const { user, session } = requireAuthSession(event)
})
pages/index.vue
<script setup>
const user = useUser()
const authenticatedUser = useAuthenticatedUser()
</script>

<template>
  {{ user?.email }}
  {{ authenticatedUser.email }}
</template>

These are just some examples.


Copyright © 2024