clerk-vue-patterns

द्वारा clerk

Vue 3 पैटर्न्स 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 की और Skills

clerk-monorepo
clerk
clerk/javascript SDK मोनोरेपो में प्रभावी ढंग से काम करें। रेपो सेट अप करते समय, पैकेज बनाने / परीक्षण करने / चलाने के लिए, और @clerk/* में से कौन सा चुनने का निर्णय लेते समय उपयोग करें...
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
मोज़ेक स्टेट मशीनों को लिखें और उपयोग करें। उपयोग तब करें जब उपयोगकर्ता createMachine के साथ स्टेट मशीन लिख रहा हो, बहु-चरणीय प्रवाह का मॉडल बना रहा हो, मशीन को React से जोड़ रहा हो…
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
Astro पैटर्न Clerk के साथ — middleware, SSR पेज, आइलैंड कंपोनेंट्स, API रूट्स, स्टैटिक बनाम SSR रेंडरिंग। ट्रिगर: astro clerk, clerk astro middleware,…
official
clerk-backend-api
clerk
Clerk बैकएंड REST API अन्वेषक और निष्पादक। टैग ब्राउज़ करें, एंडपॉइंट स्कीमा निरीक्षण करें, और प्रमाणित अनुरोध निष्पादित करें। उपयोग करें जब उपयोगकर्ताओं को सूचीबद्ध करना, प्रबंधित करना…
official
clerk-chrome-extension-patterns
clerk
Chrome एक्सटेंशन में @clerk/chrome-extension के साथ प्रमाणीकरण -- popup/sidepanel सेटअप, वेब ऐप के माध्यम से OAuth/SAML के लिए syncHost, सेवा कर्मियों के लिए 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