What will we build?

In this quickstart, we will add the Frontegg embedded login box to your Vue application.

In 5 minutes from now (start your stopwatch), your application will have a login box with Sign-in, Signup, and SSO. All this with just a few lines of code.

⚑️ The code in the sample below is available in our Frontegg Samples repository in GitHub ⚑️

Ready to start?

alt textalt text

⚑ Before you start: ⚑


Getting your Frontegg subdomain

Frontegg creates a unique subdomain for every workspace created on the account. In order to retrieve the subdomain that will act as the baseUrl in the integration, navigate to your workspace administration menu, and copy the workspace domain.

You will need them for this guide.

STEP 1: Create a New Vue application


If you have an existing app, skip this step.

To create a new app, use the following script.

vue create my-project
cd my-project

STEP 2: Install Frontegg Libraries

Run the following command to Install frontegg Vue.JS library.

npm install @frontegg/vue
yarn add @frontegg/vue

STEP 3: Configuration

Add Frontegg to the main application.

import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import { Frontegg } from '@frontegg/vue';

const router = new VueRouter({
  mode: 'history',

Vue.use(Frontegg, {
  contextOptions: {
    baseUrl: 'https://[YOUR_SUBDOMAIN].frontegg.com',

new Vue({
  render: h => h(App),

Wrap your application on the fronteggLoaded attribute to make sure you have the right context.

  <div id="app" v-if="fronteggLoaded">
    <img alt="Vue logo" src="./assets/logo.png" />

STEP 4: Getting the user context

Frontegg exposes the user context and the authentication state via a global set of mixins and state mappers. You can access the authentication state via the mappedAuthState as in the following sample:

  <div id="app" v-if="fronteggLoaded">
    <div v-if="this.authState.user">
      <span>Logged in as: {{this.authState.user.name}}</span>
      <button v-if="this.authState.user" v-on:click="logout">Logout</button>
      <button v-if="this.authState.user" v-on:click="showAccessToken">What is my access token?</button>
      <button v-if="!this.authState.user" v-on:click="goToLogin">Login</button>

export default {
  name: "App",
  created() {
    if (!this.authState.user) {
  methods: {
    goToLogin() {
    showAccessToken() {
    logout() {
  data() {
    return {

STEP 5: Run the app, signup & login

We are all set. Let's run the application and see Frontegg in action.

npm run serve
yarn run serve

Great, Frontegg is now integrated with your app!

Login and logout routes have been added to your app:

  • Signup screen is at http://localhost:8080/account/sign-up
  • Login screen is at http://localhost:8080/account/login

If you are already logged in, go to http://localhost:8080/account/logout and log out.

Give it a try now!

Open http://localhost:8080/account/sign-up and sign up with your first user.

Did this page help you?