clerk-vue-patterns

tarafından clerk

Vue 3 desenleri Clerk ile — composable'lar (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

clerk tarafından daha fazla skill

clerk-monorepo
clerk
clerk/javascript SDK monorepo'sunda etkili bir şekilde çalışın. Depoyu kurarken, bir paketi derlerken/test ederken/çalıştırırken, @clerk/*… paketlerinden hangisini kullanacağınıza karar verirken kullanın.
official
mosaic
clerk
Work on Mosaic UI: styling a component with slot recipes (`defineSlotRecipe` / `useRecipe` / slots / variants), or building a flow — authoring a state machine…
official
mosaic-machine
clerk
Mosaic durum makinelerini yazın ve kullanın. Kullanıcının createMachine ile bir durum makinesi yazdığı, çok adımlı bir akış modellediği, bir makineyi React'e bağladığı durumlarda kullanın.
official
clerk-android
clerk
Implement Clerk authentication for native Android apps using Kotlin and Jetpack Compose with clerk-android source-guided patterns. Use for prebuilt…
official
clerk-astro-patterns
clerk
Clerk ile Astro desenleri — middleware, SSR sayfaları, island bileşenleri, API route'ları, statik ve SSR render etme. Tetikleyiciler: astro clerk, clerk astro middleware,…
official
clerk-backend-api
clerk
Clerk Backend REST API gezgini ve yürütücüsü. Etiketlere göz atın, uç nokta şemalarını inceleyin ve kimliği doğrulanmış istekler yürütün. Kullanıcıları listelerken, yönetirken… kullanın.
official
clerk-chrome-extension-patterns
clerk
Chrome Eklentisi kimlik doğrulaması @clerk/chrome-extension ile -- popup/sidepanel kurulumu, web uygulaması üzerinden OAuth/SAML için syncHost, service worker'lar ve… için createClerkClient
official
clerk-cli
clerk
Operate the Clerk CLI (`clerk` binary) for authentication, user/org/session management, impersonation, local webhook testing, deploy verification, instance…
official