Vue Quickstart
You will learn the following:
- Create a new Vue app using Vite
- Install
@clerk/vue
- Set your Clerk API keys
- Add
clerkPlugin
- Create a header with Clerk components
Clerk's Vue SDK provides prebuilt components and composables to make it easy to integrate authentication and user management in your Vue app. This guide assumes that you're using Vue 3 with TypeScript.
Create a Vue app using Vite
Run the following commands to create a new Vue app using Vite:
Install @clerk/vue
Clerk's Vue SDK gives you access to prebuilt components, composables, and helpers to make user authentication easier.
Run the following command to install the SDK:
Add your Clerk Publishable Key to your .env.local
file. This key can always be retrieved from the API Keys page in the Clerk Dashboard.
- In the Clerk Dashboard, navigate to the API Keys page.
- In the Quick Copy section, copy your Clerk Publishable Key.
- Paste your key into your
.env.local
file.
The final result should resemble the following:
Import the Clerk Publishable Key
In your main.ts
file, import your Clerk Publishable Key. You can add an if
statement to check that the key is imported properly. This prevents the app from running without the Publishable Key and catches TypeScript errors.
Add clerkPlugin
to your app
clerkPlugin
provides active session and user context to Clerk's components and composables. It's required to pass your Publishable Key as an option.
Create a header with Clerk components
You can control which content signed-in and signed-out users can see with Clerk's prebuilt control components. The following example creates a header using the following components:
<SignedIn>
: Children of this component can only be seen while signed in.<SignedOut>
: Children of this component can only be seen while signed out.<UserButton />
: Shows the signed-in user's avatar. Selecting it opens a dropdown menu with account management options.<SignInButton />
: An unstyled component that links to the sign-in page or displays the sign-in modal.
Create your first user
Run your project with the following command:
Visit your app's homepage at http://localhost:5173
. Sign up to create your first user.
Feedback
Last updated on