Skip to content

Add passkeys to your Vue.js and Express application using the Corbado passkey-first authentication solution.

Notifications You must be signed in to change notification settings

corbado/passkeys-vuejs-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repo Cover

Vue.js and Express Passkey Example App

This is a sample implementation of the Corbado passkeys-first authentication solution using Vue.js and Express. The following packages are being used:

File structure

  • frontend: Separate directory for the Vue.js frontend
  • frontend/.env.example: Example file for environment variables
  • frontend/src/views: Contains all pages used in the frontend
  • frontend/src/router/index.ts: Contains the route definitions
  • frontend/src/stores/user.ts: Global store for user data from Corbado and our own backend
  • backend: Separate directory for the Express.js backend
  • backend/.env.example: Example file for environment variables
  • backend/src/app.ts: Configuration file for the Express app
  • backend/src/utils: Collection of utility functions, e.g. helper functions for authentication
  • backend/src/routes: Directory configuring the routes for the app
  • backend/src/controller: Controllers for the routes
  • backend/src/middleware: Middleware, e.g. for authentication
  • backend/src/db: Database configuration and queries

Setup

Prerequisites

Please follow the steps in Getting started to create and configure a project in the Corbado developer panel.

You need to have Node and npm installed to run it.

Configure environment variables

Use the values you obtained in Prerequisites to configure the following variables inside a .env file you create in frontend and backend directories respectively:

Backend

The backend needs an api secret to authenticate with the Corbado backend API.

CORBADO_PROJECT_ID=pro-XXX
CORBADO_API_SECRET=corbado1_XXX
CORBADO_FRONTEND_API=https://{$CORBADO_PROJECT_ID}.frontendapi.cloud.corbado.io
CORBADO_BACKEND_API=https://backendapi.cloud.corbado.io

Frontend

The frontend needs the project ID and the backend base URL.

VITE_CORBADO_PROJECT_ID=pro-XXX
VITE_BACKEND_BASE_URL=http://localhost:3001

Usage

Run the project locally

Run the following command in the root directory

(cd backend && npm install)
(cd frontend && npm install)

to install all dependencies.

Finally, you can run the project locally with the provided start script or individually for frontend and backend.

Using the start script

./start.sh

Running frontend and backend individually

In one terminal session, run the following command in the frontend directory:

npm run dev

In another terminal session, run the following command in the backend directory:

npm run start

Passkeys support