Composables
useSurrealAuth
Retrieve the currently authenticated user info.
useSurrealAuth
Returns the record of the currently authenticated user by selecting the $auth parameter from SurrealDB.
Make sure the user has permission to select their own record, otherwise an empty result is returned.
Usage
app/pages/profile.vue
<script setup lang="ts">
const { data: user } = await useSurrealAuth<{ name: string }>()
</script>
<template>
<div v-if="user">
Logged in as: {{ user.name }}
</div>
</template>
Arguments
| Argument | Type | Description |
|---|---|---|
asyncDataOptions? | AsyncDataOptions | Options passed to useAsyncData |
Return type
Returns the same shape as useSurrealAsyncData, with data typed as the authenticated user record or undefined.