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.

referencespinia-integration.md

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

Pinia Integration

Auth Store (Thin Wrapper)

Wrap useAuth in a Pinia store for app-wide access without prop drilling:

// stores/auth.ts
import { defineStore } from 'pinia'
import { useAuth, useUser } from '@clerk/vue'

export const useAuthStore = defineStore('auth', () => {
  const { isSignedIn, isLoaded, userId, signOut, getToken } = useAuth()
  const { user } = useUser()

  return {
    isSignedIn,
    isLoaded,
    userId,
    user,
    signOut,
    getToken,
  }
})

Usage in components:

<script setup lang="ts">
import { useAuthStore } from '@/stores/auth'

const auth = useAuthStore()
</script>

<template>
  <p v-if="auth.isSignedIn">{{ auth.user?.firstName }}</p>
</template>

Org Store

// stores/org.ts
import { defineStore } from 'pinia'
import { useOrganization, useOrganizationList } from '@clerk/vue'

export const useOrgStore = defineStore('org', () => {
  const { organization, membership } = useOrganization()
  const { userMemberships, setActive } = useOrganizationList()

  function switchOrg(orgId: string) {
    return setActive.value!({ organization: orgId })
  }

  return {
    organization,
    membership,
    userMemberships,
    switchOrg,
  }
})

CRITICAL

  • Do NOT copy userId into Pinia state manually — it creates a stale copy. Always return refs directly from composables
  • Pinia store setup() function runs inside Vue's setup context — composables work correctly here

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.