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-testing
clerk
Clerk kimlik doğrulama akışları için Playwright ve Cypress'te E2E test yardımcı programları. Hem Playwright hem de Cypress çerçevelerini, çerçeveye özgü kurulum desenleriyle (Playwright için globalSetup, Cypress için özel komutlar) destekler. Test ortamlarını başlatmak ve bot algılamayı atlamak için clerkSetup() ve setupClerkTestingToken() yardımcı programlarını sağlar. Test yürütme süresini azaltmak için testler arasında kimliği doğrulanmış oturumları yeniden kullanmak üzere storageState kalıcılığını içerir. Test API anahtarları (pk_test_*, ...) gerektirir.
clerk-swift
clerk
ClerkKit ile Native Swift/iOS kimlik doğrulaması, önceden oluşturulmuş veya özel kimlik doğrulama akışları kullanılarak gerçekleştirilir. Proje gereksinimlerine göre seçilen iki uygulama modunu destekler: önceden oluşturulmuş AuthView bileşenleri veya tamamen özel native akışlar. Uygulama yapılandırmasında geçerli bir Clerk yayınlama anahtarının doğrudan bağlanmasını gerektirir; varsayılan olarak plist veya ortam dosyası yönlendirmesi kullanmaz. Paket kurulumundan sonra, özellik kullanılabilirliğini (örneğin Apple Sign In desteği) belirlemek için zorunlu /v1/environment
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
Abonelik yönetimi için Clerk Billing - Clerk'in PricingTable'ını render eder
clerk-nextjs-patterns
clerk
We need to translate the given English text into Turkish, preserving the name "clerk-nextjs-patterns" if it appears. The text is a description of an agent skill. We must not add any extra commentary, labels, or formatting. The translation should be accurate and natural in Turkish, keeping technical terms like "Next.js", "Clerk", "auth()", "useAuth()", "unstable_cache", "Server Actions", "API route", "HTTP status codes", "401", "403", "Core 2" as is. Also preserve "middleware", "authentication", "user-scoped caching", etc. but translate the surrounding words. The 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
clerk-expo-patterns
clerk
Expo / React Native desenleri Clerk ile — SecureStore token önbelleği, 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-astro-patterns
clerk
Clerk ile Astro desenleri — middleware, SSR sayfaları, ada bileşenleri,