Skip to main content

Vue Quickstart

Cloud has the newest features. Some may not be in a release yet; the newest release is Identity & Access Management 7.3.0.

Use this guide to add Choreo Identity & Access Management authentication to a Vue 3 application using the @thunderid/vue SDK.

Get the complete sample

What You Will Learn​

  • Create a new Vue 3 app using Vite
  • Install the @thunderid/vue package
  • Add working sign-in and sign-out
  • Display the signed-in user's profile

Prerequisites​

  • About 15 minutes
  • Node.js installed on your system
  • npm, yarn, or pnpm
  • Your preferred code editor

Create an Application​

  1. Sign in to the Console at https://console.cloud.choreolabs.com/iam/. Select your project in the project switcher in the header.
  2. Navigate to Applications.
  3. Click Add application.
  4. From the Choose a type page, select Vue.
  5. Enter a name (e.g. My Vue App).
  6. Click Create.
  7. Select how you want to sign in users (e.g., email/password, social login, etc.).
  8. Select Theme settings and other options.
  9. In the Configuration step, click on the banner to add Vite's development server URL to the list of Authorized redirect URIs & CORS allowed origins. The default is http://localhost:5173 (adjust the port if your dev server uses a different one).
Note

Copy the Client ID from the General tab. You'll need it when configuring the SDK.

Data plane URL

Code in this guide uses https://<DATA_PLANE_URL> for your environment's data plane URL, where users sign in and tokens are issued. Replace it with the URL on the environment's Endpoints page. To open it, select your project, go to Deployment pipeline, and click Open environment on the environment's card. See Control Plane and Data Plane URLs.

Deploy your changes

Saving a change does not make it live. You author in the control plane, and your users sign in on a separate data plane, so a change takes effect in an environment only after you deploy it. Go to Deploy, deploy the latest version to your first environment, then promote it to the next environment when you are ready.

Auto-sync deploys saved changes to your first environment within seconds. Turning it on is your choice, per project. See Deploy a Version, or learn why you deploy and how auto-sync works.

Create a Vue App​

Create your new Vue 3 app using Vite:

npm create vite@latest my-vue-app -- --template vue
cd my-vue-app
npm install

Install @thunderid/vue​

Install the Choreo Identity & Access Management Vue SDK in your project:

npm install @thunderid/vue

Register the Plugin​

Register ThunderIDPlugin in src/main.js:

src/main.js
import { createApp } from 'vue'
import { ThunderIDPlugin } from '@thunderid/vue'
import './style.css'
import App from "./App.vue"

const app = createApp(App)
app.use(ThunderIDPlugin)
app.mount('#app')

Build with Choreo Identity & Access Management Components​

Update src/App.vue with Choreo Identity & Access Management authentication components:

Configuration

Replace <your-client-id> with the Client ID you obtained when creating the application in Choreo Identity & Access Management.

src/App.vue
<script setup>
import {
SignedIn,
SignedOut,
SignInButton,
SignOutButton,
UserDropdown,
} from '@thunderid/vue'
</script>

<template>
<ThunderIDProvider
client-id="<your-client-id>"
base-url="https://<DATA_PLANE_URL>"
>
<section id="center">
<SignedIn>
<UserDropdown />
</SignedIn>
<SignedOut>
<SignInButton>Sign In</SignInButton>
</SignedOut>
</section>
</ThunderIDProvider>
</template>

Run Your App​

Start the development server:

npm run dev
Test credentials

You'll need a user to sign in with. If you haven't created one yet, open https://console.cloud.choreolabs.com/iam/, navigate to Users, and add a test user with an email and password.

Success

Visit your app at 🌐 http://localhost:5173

You should see the <SignInButton />. Click it to be redirected to the Choreo Identity & Access Management-hosted sign-in page. Login with your test user, then return to your app with the user dropdown displayed.

Run the Sample App​

The Vue sample is a working version of the app this guide builds. To run it instead of building the app yourself:

  1. Download the sample from its releases and open its folder.

  2. Create .env in the sample's folder with your application's values:

    .env
    VITE_THUNDERID_BASE_URL=https://<DATA_PLANE_URL>
    VITE_THUNDERID_CLIENT_ID=<your-client-id>
  3. Install the dependencies and start the app:

    npm install
    npm run dev
  4. Open http://localhost:5173 and sign in.

What's Next​

Was this page helpful?