clerk-vue-patterns

작성자: clerk

Vue 3 패턴 with Clerk — 컴포저블 (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의 다른 스킬

clerk-testing
clerk
Clerk 인증 흐름을 위한 Playwright 및 Cypress E2E 테스트 유틸리티입니다. Playwright와 Cypress 프레임워크를 모두 지원하며, 각 프레임워크에 맞는 설정 패턴(Playwright의 globalSetup, Cypress의 커스텀 명령어)을 제공합니다. 테스트 환경을 초기화하고 봇 탐지를 우회하기 위해 clerkSetup()과 setupClerkTestingToken() 유틸리티를 제공합니다. 인증된 세션을 테스트 간에 재사용하여 테스트 실행 시간을 줄이는 storageState 지속성을 포함합니다. 테스트 API 키(pk_test_* ,...)가 필요합니다.
clerk-swift
clerk
ClerkKit을 사용한 네이티브 Swift/iOS 인증으로, 사전 구축된 인증 흐름 또는 맞춤형 인증 흐름을 지원합니다. 프로젝트 요구 사항에 따라 사전 구축된 AuthView 컴포넌트 또는 완전히 맞춤화된 네이티브 흐름 중 두 가지 구현 모드를 지원합니다. 앱 구성에 유효한 Clerk 퍼블리시 키를 직접 연결해야 하며, 기본적으로 plist나 환경 파일 간접 참조를 사용하지 않습니다. 패키지 설치 후 Apple Sign In 지원 등 기능 가용성을 확인하기 위해 /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
구독 관리를 위한 Clerk Billing - Clerk의 PricingTable을 렌더링합니다.
clerk-nextjs-patterns
clerk
Clerk를 사용한 인증, 미들웨어, 서버 액션, 사용자 범위 캐싱을 위한 고급 Next.js 패턴. 서버 측 await auth()와 클라이언트 측 useAuth() 훅을 구분하며, 이 둘을 혼용하는 것은 흔한 치명적 실수입니다. 미들웨어 전략(퍼블릭 우선 vs 보호 우선), API 라우트 보호, 적절한 HTTP 상태 코드(401 vs 403)를 다룹니다. unstable_cache를 사용한 사용자 범위 캐싱 패턴과 승인되지 않은 변이로부터 서버 액션을 보호하는 방법을 포함합니다. Core 2 호환성을 제공합니다...
clerk-expo-patterns
clerk
Expo / React Native 패턴과 Clerk — 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-astro-patterns
clerk
Clerk을 사용한 Astro 패턴 — 미들웨어, SSR 페이지, 아일랜드 컴포넌트