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.

SKILL.md

≈75 tokens always: the name and description. ≈605 when used: this file. ≈1.9k more on demand in 5 files.

Vue Patterns

SDK: @clerk/vue v2+ (Vue 3). For Nuxt, use clerk-nuxt-patterns.

What Do You Need?

Task Reference
Composables: useAuth, useUser, useOrganization references/composables.md
Vue Router navigation guards references/vue-router-guards.md
Pinia store with auth state references/pinia-integration.md

Mental Model

Vue uses composables from @clerk/vue:

  • useAuth() — reactive isSignedIn, userId, signOut
  • useUser() — reactive user object
  • useClerk() — full Clerk instance for advanced operations
  • useOrganization() — reactive organization, membership

Setup

Vue (Plain)

// main.ts
import { clerkPlugin } from '@clerk/vue'
import { createApp } from 'vue'
import App from './App.vue'

const app = createApp(App)
app.use(clerkPlugin, {
  publishableKey: import.meta.env.VITE_CLERK_PUBLISHABLE_KEY,
})
app.mount('#app')

Composables Usage

<script setup lang="ts">
import { useAuth, useUser } from '@clerk/vue'

const { isSignedIn, userId, signOut } = useAuth()
const { user } = useUser()
</script>

<template>
  <div v-if="isSignedIn">
    <p>Hello {{ user?.firstName }}</p>
    <button @click="signOut()">Sign Out</button>
  </div>
  <SignInButton v-else />
</template>

Org Switching

<script setup lang="ts">
import { useOrganizationList } from '@clerk/vue'

const { userMemberships, setActive } = useOrganizationList()
</script>

<template>
  <button
    v-for="mem in userMemberships.data ?? []"
    :key="mem.organization.id"
    @click="setActive({ organization: mem.organization.id })"
  >
    {{ mem.organization.name }}
  </button>
</template>

Common Pitfalls

Symptom Cause Fix
Composables return undefined Not inside ClerkProvider tree Ensure app.use(clerkPlugin, { publishableKey }) is called
userId reactive but not updating Destructuring loses reactivity Use const { userId } = useAuth() (toRefs-style composable, reactive)

Import Map

What Import
Composables @clerk/vue
Plugin setup @clerk/vue
Components @clerk/vue

See Also

  • clerk-setup - Initial Clerk install
  • clerk-custom-ui - Custom flows & appearance
  • clerk-orgs - B2B organizations

Docs

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 20 hours ago.

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.