clerk-vue-patterns

par clerk

Modèles Vue 3 avec Clerk — composables (useAuth, useUser,

npx skills add https://github.com/clerk/skills --skill clerk-vue-patterns

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

Plus de skills de clerk

mosaic
clerk
Work on Mosaic UI: styling a component with slot recipes (`defineSlotRecipe` / `useRecipe` / slots / variants), or building a flow — authoring a state machine…
clerk-billing
clerk
Gestion des abonnements Clerk Billing - afficher le PricingTable de Clerk
clerk-nextjs-patterns
clerk
We need to translate the given text from English to French. The text describes an agent skill for Clerk Next.js patterns. We must preserve the name "clerk-nextjs-patterns" but it's not in the text, so we don't include it. We translate only the text inside <text>. No extra labels. Keep technical terms like "Next.js", "Clerk", "auth()", "useAuth()", "unstable_cache", "Server Actions", "Core 2" as is. Translate the rest naturally. Text: "Advanced Next.js patterns for authentication, middleware, Server Actions, and user-scoped caching with Clerk. Distinguishes server-side await auth() from client-side useAuth() hook; mixing them is a common breaking mistake Covers middleware strategies (public-first vs protected-first), API route protection, and proper HTTP status codes (401 vs 403) Includes user-scoped caching patterns with unstable_cache and protecting Server Actions from unauthorized mutations Provides Core 2 compatibility..." Translation: "Modèles avancés Next.js pour l'authentification,
clerk-expo-patterns
clerk
Modèles Expo / React Native avec Clerk — Cache de jetons SecureStore, OAuth
changesets
clerk
Create or refresh a `.changeset/<slug>.md` for the current branch, or report that none is required. Triggers on "/changesets create", "add a changeset",…
clerk
clerk
Le binaire clerk est une passerelle pré-authentifiée vers l'API Backend et l'API Platform de Clerk, ainsi que des outils au niveau du projet (authentification, liaison, récupérations d'environnement, configuration d'instance). Lorsque l'utilisateur demande quoi que ce soit qui touche à une ressource Clerk, utilisez clerk en premier lieu plutôt que de bricoler une commande curl.
clerk-cli
clerk
Le binaire clerk est une passerelle pré-authentifiée vers l'API Backend et l'API Platform de Clerk, ainsi que des outils au niveau du projet (auth, linking, env pulls, configuration d'instance). Lorsque l'utilisateur demande quoi que ce soit qui touche à une ressource Clerk, utilisez clerk en premier plutôt que de faire un curl à la main.
clerk-astro-patterns
clerk
Modèles Astro avec Clerk — middleware, pages SSR, composants îlots,