This is a sample implementation of the passkey solution integrated into a web application built with Next.js (frontend) and Node.js (backend).
/frontend-nextjs/src/app/page.tsx
: Page with the login / home screen./frontend-nextjs/src/pages/profile.tsx
: Page with the profile screen after authentication./frontend-nextjs/src/declarations.d.ts
: page for the user profile information that is shown after successful authentication.
/backend-nodejs/index.js
: main entry point for the backend server.
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. Also, you need to
install Next.js if you haven't done so.
⚠️ Email address change: Please note, that you need to change the email address in/frontend-nextjs/src/pages/profile.tsx
(dynamically) to test the association token creation process, and thus the passkey associate process, multiple times.
cd frontend-nextjs
Copy the .env.example
file, rename it to .env
and fill the values for NEXT_PUBLIC_PROJECT_ID
with your Corbado project ID you obtained in prerequisites and NEXT_PUBLIC_API_BASE_URL
with the URL of your backend. The default value for this repository is http://localhost:3001
.
npm i
to install all dependencies.
npm run dev
This starts the frontend on PORT=3000
.
Now, open a new terminal and navigate to the backend folder:
cd ../backend-nodejs
Copy the .env.example
file, rename it to .env
and fill the values for PROJECT_ID
and API_SECRET
with your Corbado project ID and API secret you obtained in prerequisites.
npm i
node index.js
The application should now be running on your local machine, with your backend running on PORT=3001
.