All skills
clerk avatar

/clerk-vue-patterns

@7ad2635 official
by clerkclerk/skills83 stars
5

Vue 3 patterns with Clerk — composables (useAuth, useUser, useClerk, useOrganization), Vue Router guards, Pinia auth store integration. Triggers on: vue clerk, useAuth vue, clerk composables, vue router clerk guard, pinia auth clerk. For Nuxt, use clerk-nuxt-patterns instead.

Use this Skill: https://skilld.dev/gh/clerk/skills/clerk-vue-patterns

This session only. Nothing lands on disk.

referencescomposables.md

≈551 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Composables

All composables come from @clerk/vue.

useAuth

import { useAuth } from '@clerk/vue'

const { isSignedIn, isLoaded, userId, sessionId, signOut, getToken } = useAuth()
Property Type Description
isSignedIn Ref<boolean> True when user is authenticated
isLoaded Ref<boolean> True when Clerk has initialized
userId Ref<string | null> Current user ID
sessionId Ref<string | null> Current session ID
signOut() function Sign out and clear session
getToken() async function Get JWT for external APIs

useUser

import { useUser } from '@clerk/vue'

const { user, isLoaded } = useUser()

user is Ref<UserResource | null> with .firstName, .lastName, .fullName, .imageUrl, .primaryEmailAddress, etc.

useClerk

import { useClerk } from '@clerk/vue'

const clerk = useClerk()
await clerk.value.openSignIn()
await clerk.value.openUserProfile()

Use for programmatic UI control (open modals, redirect, etc.).

useOrganization

import { useOrganization } from '@clerk/vue'

const { organization, membership, isLoaded } = useOrganization()

organization is Ref<Organization | null>. membership includes role.

useOrganizationList

import { useOrganizationList } from '@clerk/vue'

const { userMemberships, setActive } = useOrganizationList()

userMemberships.data is an array of memberships. Call setActive({ organization: id }) to switch.

useSignIn / useSignUp

import { useSignIn } from '@clerk/vue'

const { signIn, setActive, isLoaded } = useSignIn()

async function submit(email: string, password: string) {
  const result = await signIn.value!.create({
    identifier: email,
    password,
  })
  if (result.status === 'complete') {
    await setActive.value!({ session: result.createdSessionId })
  }
}

CRITICAL

  • All composables return refs — access values with .value outside of templates
  • Check isLoaded before rendering auth-gated UI to prevent flashes
  • useOrganizationList returns userMemberships as a paginated resource — access .data for the array

Source: SKILL.md on GitHub

No alerts16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides legitimate Vue 3 patterns and templates for integrating Clerk authentication. It follows security best practices and contains no malicious code or exfiltration patterns.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7ad2635. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 6 months ago
What it can do
Network
metadata
{
  "author": "clerk",
  "version": "1.0.0"
}
All 1 allowed tools
WebFetch
  • Vue
  • clerk
  • composables
  • authentication
  • vue-router
  • pinia
  • organizations

README badge

README badge for clerk/skills/clerk-vue-patterns

Provides Clerk auth composables and patterns for Vue 3, including useAuth, useUser, useOrganization, Vue Router guards, and Pinia store integration. Targets @clerk/vue v2+ and assumes you're building with plain Vue rather than Nuxt.

Generated from the current SKILL.md.

Does this skill cover Nuxt?
No. This skill targets Vue 3 with @clerk/vue. For Nuxt, use clerk-nuxt-patterns instead.
What composables does this skill teach?
useAuth, useUser, useClerk, and useOrganization — all from @clerk/vue v2+. Each provides reactive access to auth state, user data, and organization context.
Does this include Vue Router integration?
Yes. The skill covers Vue Router navigation guards for protecting routes based on auth state.
Can I use this with a Pinia store?
Yes. The skill includes a reference for integrating Clerk auth state with Pinia.
Why are my composables returning undefined?
Composables must be called inside the ClerkProvider tree. Ensure app.use(clerkPlugin, { publishableKey }) is invoked in main.ts.

Generated from the current SKILL.md. These answers refresh after source changes.