Skip to content

Node.js (Express) repository of a sample app that offers passkey authentication.

Notifications You must be signed in to change notification settings

corbado/example-passkeys-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js (Express) Passkey Example App

This is a sample implementation of frontend and backend where the Corbado Node.js SDK and Web-js components are integrated in an Express application.

1. File structure

├── ...
├── .env                        # Environment variables for the application
├── src                             
│   ├── app.ts                  # Application Entrypoint
│   ├── routes.ts               # Defines our routes 
│   ├── authController.ts       # Handles all of our endpoints
│   └── userService.ts          # Service to manage User data
└── ...

2. Setup

2.1. Configure environment variables

Please follow our Getting started page to create and configure a project in the developer panel.

Use the values you obtained above to configure the following variables inside .env:

  1. CORBADO_PROJECT_ID: The project ID.
  2. CORBADO_API_SECRET: The API secret.
  3. CORBADO_FRONTEND_API: The frontend API URL.
  4. CORBADO_BACKEND_API: The backend API URL.

2.2. Run the Express App

Use the following command to install all dependencies:

npm i

Now, you're ready to run the app like this:

npm run start

3. Usage

After step 2 your local server should be fully working.

3.1. Test authentication

If you now visit http://localhost:3000, you should be seeing our authentication UI.

Create an account and take a look at the profile page under /profile you'll be forwarded to.