useSupabaseUser


Once logged in, you can auto-import your user everywhere inside your vue files.

<script setup>const user = useSupabaseUser()</script>

Auth middleware

You can protect your authenticated routes by creating a custom middleware in your project, here is an example:

middleware/auth.ts
export default defineNuxtRouteMiddleware((to, _from) => {  const user = useSupabaseUser()  if (!user.value) {    return navigateTo('/login')  }})

Then you can reference your middleware in your page with:

pages/dashboard.vue
definePageMeta({  middleware: 'auth'})

Learn more about Nuxt middleware and definePageMeta.