Generated banner for Clerk Vue Patterns
Generated logo for Clerk Vue Patterns

Clerk Vue Patterns

ClerkOfficialCreated by clerk

  • Skill
  • Tool integration
  • Software development
  • MIT
  • Low risk
  • Has scripts

From the author

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.
— the description by clerk

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides essential patterns for integrating Clerk authentication into Vue 3 applications. It covers the usage of core composables like useAuth, useUser, and useOrganization, demonstrates how to integrate Clerk state into Pinia stores for global access, and provides guidance on setting up Vue Router navigation guards. It is designed for developers using the @clerk/vue SDK to manage user sessions, organization switching, and protected routes.

What it does

  • Provides patterns for using Clerk composables in Vue 3 components.
  • Demonstrates how to wrap Clerk authentication state in Pinia stores.
  • Explains how to implement navigation guards for route protection.
  • Shows how to manage organization switching and membership data.
  • Offers troubleshooting tips for common reactivity and initialization issues.

When to use it

  • When setting up Clerk authentication in a new Vue 3 project.
  • When you need to access user or session state globally via Pinia.
  • When implementing protected routes that require authenticated users.
  • When building multi-tenant applications using Clerk organizations.
  • When debugging issues with reactive Clerk composables.

Advantages

  • Ensures consistent implementation of authentication across the application.
  • Reduces prop drilling by leveraging Pinia for auth state management.
  • Provides clear guidance on maintaining reactivity with Vue composables.
  • Includes specific patterns for complex features like organization switching.

Usage examples

“How do I access the current user's information in a Vue component?”
The skill provides a pattern using the useUser composable to access reactive user properties like firstName and imageUrl.
“How can I make Clerk auth state available globally in my Pinia store?”
It provides a code template for a Pinia store that wraps useAuth and useUser, ensuring state remains reactive and synchronized.
“How do I switch organizations in my Vue app?”
It demonstrates using the useOrganizationList composable to list memberships and the setActive function to switch the active organization.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/clerk/clerk-vue-patterns/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip clerk-vue-patterns.zip -d .agents/skills

Documentation by clerk

Vue Patterns

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

What Do You Need?

TaskReference
Composables: useAuth, useUser, useOrganizationreferences/composables.md
Vue Router navigation guardsreferences/vue-router-guards.md
Pinia store with auth statereferences/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

SymptomCauseFix
Composables return undefinedNot inside ClerkProvider treeEnsure app.use(clerkPlugin, { publishableKey }) is called
userId reactive but not updatingDestructuring loses reactivityUse const { userId } = useAuth() (toRefs-style composable, reactive)

Import Map

WhatImport
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

Files

evals/evals.json

{
  "skill_name": "clerk-vue-patterns",
  "evals": [
    {
      "id": 1,
      "prompt": "show me how to use clerk composables in a vue 3 component to display the user's name and a sign-out button.",
      "expected_output": "Uses useAuth and useUser composables from @clerk/vue, shows user.firstName, calls signOut()",
      "scaffold": "vue-basic-auth",
      "expectations": [
        "Imports useAuth and useUser from @clerk/vue",
        "Uses isSignedIn from useAuth to conditionally render",
        "Accesses user.firstName or user.fullName from useUser",
        "Calls signOut() from useAuth on button click",
        "Handles the case where user is not signed in"
      ]
    },
    {
      "id": 2,
      "prompt": "i want to build a custom sign-in form in vue using clerk's useSignIn composable. show the email/password flow.",
      "expected_output": "Uses useSignIn composable, calls signIn.create with identifier and password, sets active session after success",
      "scaffold": "vue-basic-auth",
      "expectations": [
        "Imports useSignIn from @clerk/vue",
        "Destructures signIn and setActive from useSignIn",
        "Calls signIn.create({ identifier, password }) on form submit",
        "Calls setActive({ session: signIn.createdSessionId }) after successful sign-in",
        "Handles errors from the sign-in attempt"
      ]
    },
    {
      "id": 3,
      "prompt": "i want a pinia store that syncs with clerk auth state. the store should expose isAuthenticated and userId, and update reactively when the user signs in or out.",
      "expected_output": "Creates a Pinia store that uses useAuth composable, exposes isSignedIn and userId as computed values",
      "scaffold": "vue-basic-auth",
      "expectations": [
        "Creates a Pinia store using defineStore",
        "Calls useAuth inside the store setup function",
        "Exposes isSignedIn (or renamed isAuthenticated) from useAuth",
        "Exposes userId from useAuth",
        "Does NOT duplicate auth state — wraps useAuth reactivity rather than copying it"
      ]
    }
  ]
}

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools, Needs Node.js

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
clerk
Publisher
Clerk (Official)
Source
clerk/skills · skills/clerk-vue-patterns · commit c5d2c0d
Licence
MIT License (redistribution allowed)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by clerk or Clerk.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download clerk-vue-patterns.zip