Skip to content

Commit cfd8a6d

Browse files
authored
docs(nuxt): Use event.context.auth as a function (#2182)
1 parent 9d97c4d commit cfd8a6d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

docs/authentication/configuration/force-mfa.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ By default, Clerk does not enforce [multi-factor authentication (MFA)](/docs/aut
128128
const isMFARoute = event.path.startsWith('/account/manage-mfa/add')
129129
const isSignInRoute = event.path.startsWith('/sign-in')
130130

131-
const { userId, sessionClaims } = event.context.auth
131+
const { userId, sessionClaims } = event.context.auth()
132132

133133
// Redirect to homepage if the user is signed in and on the sign-in page
134134
if (userId !== null && isSignInRoute) {

docs/references/nuxt/clerk-middleware.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ In the following example, the `clerkMiddleware()` helper checks if the user is s
4848
import { clerkMiddleware } from '@clerk/nuxt/server'
4949

5050
export default clerkMiddleware((event) => {
51-
const { userId } = event.context.auth
51+
const { userId } = event.context.auth()
5252
const isAdminRoute = event.path.startsWith('/api/admin')
5353

5454
if (!userId && isAdminRoute) {
@@ -72,7 +72,7 @@ In the following example, the `clerkMiddleware()` helper checks if the user is a
7272
import { clerkMiddleware } from '@clerk/nuxt/server'
7373

7474
export default clerkMiddleware((event) => {
75-
const { has } = event.context.auth
75+
const { has } = event.context.auth()
7676
const isInvoicesRoute = event.path.startsWith('/api/invoices')
7777
const canCreateInvoices = has({
7878
permission: 'org:invoices:create',
@@ -102,7 +102,7 @@ In the following example, the `clerkMiddleware()` helper checks if the user is a
102102
import { clerkMiddleware } from '@clerk/nuxt/server'
103103

104104
export default clerkMiddleware((event) => {
105-
const { has } = event.context.auth
105+
const { has } = event.context.auth()
106106
const isAdminRoute = event.path.startsWith('/api/admin')
107107
const isAdmin = has({
108108
role: 'org:admin',

docs/references/nuxt/overview.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Because the Nuxt SDK is built on top of the Clerk Vue SDK, you can use the compo
1313

1414
## `Auth` object
1515

16-
The `Auth` object is available at `event.context.auth` in your [event handlers](https://h3.unjs.io/guide/event-handler). This JavaScript object contains important information like session data, your user's ID, as well as their organization ID. [Learn more](/docs/references/backend/types/auth-object).
16+
The `Auth` object is available at `event.context.auth()` in your [event handlers](https://h3.unjs.io/guide/event-handler). This JavaScript object contains important information like session data, your user's ID, as well as their organization ID. [Learn more](/docs/references/backend/types/auth-object).
1717

1818
## `clerkMiddleware()`
1919

docs/references/nuxt/read-session-data.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const { isLoaded, isSignedIn, user } = useUser()
3131

3232
## Server-side
3333

34-
The `Auth` object is available at `event.context.auth` in your [event handlers](https://h3.unjs.io/guide/event-handler). This JavaScript object contains important information like the current user's session ID, user ID, and organization ID. The `userId` can be used to protect your API routes.
34+
The `Auth` object is available at `event.context.auth()` in your [event handlers](https://h3.unjs.io/guide/event-handler). This JavaScript object contains important information like the current user's session ID, user ID, and organization ID. The `userId` can be used to protect your API routes.
3535

3636
In some cases, you may need the full [`Backend User`](/docs/references/backend/types/backend-user) object of the currently active user. This is helpful if you want to render information, like their first and last name, directly from the server. The `clerkClient()` helper returns an instance of the [JavaScript Backend SDK](/docs/references/backend/overview), which exposes Clerk's Backend API resources through methods such as the [`getUser()`](/docs/references/backend/user/get-user){{ target: '_blank' }} method. This method returns the full `Backend User` object.
3737

@@ -42,7 +42,7 @@ import { clerkClient } from '@clerk/nuxt/server'
4242

4343
export default defineEventHandler(async (event) => {
4444
// Use `auth` to get the user's ID
45-
const { userId } = event.context.auth
45+
const { userId } = event.context.auth()
4646

4747
// Protect the API route by checking if the user is signed in
4848
if (!userId) {

0 commit comments

Comments
 (0)