This repository demonstrates how to add passkey login functionality to your Svelte.js and Express app using the Hanko Passkey API. Passkey authentication is a secure and user-friendly alternative to traditional password-based authentication, providing a seamless login experience for users.
For a detailed tutorial on implementing passkey login in your Svelte and Express app, refer to our blog post: Adding passkeys to a Svelte.js app
Before you begin, ensure you have the following:
Note: You'll need to create a Passkey Project on Hanko Cloud with the App URL
http://localhost:5173
. See our docs to learn how to setup a passkey project.
git clone https://github.com/teamhanko/passkeys-svelte-express
Create a .env
file in the express-backend
directory and add the following environment variables:
PASSKEYS_API_KEY=your-hanko-passkey-api-key
PASSKEYS_TENANT_ID=your-hanko-passkey-tenant-id
Replace your-hanko-passkey-api-key
and your-hanko-passkey-tenant-id
with your actual Hanko Passkey API key and tenant ID.
cd react-frontend
npm
, pnpm
, yarn
, or bun
). For this project, we've used pnpm
:pnpm install
pnpm dev
cd express-backend
pnpm install
pnpm dev
Start the application:
Ensure that both the frontend and backend servers are running.
Access the application by navigating to http://localhost:5173
in your web browser.
Log in with a pre-configured user: Navigate to login page, login with one of the pre-configured users.
{
"id": "b3fbbdbd-6bb5-4558-9055-3b54a9469629",
"email": "[email protected]",
"password": "password123",
},
{
"id": "22c81b3d-1e7d-4a72-a6b0-ad946e0c0965",
"email": "[email protected]",
"password": "very_secure_password",
},
{
"id": "55c81b3d-1e7d-4a72-a6b0-ad946e0c0965",
"email": "[email protected]",
"password": "123",
}
Register a passkey:
Log out:
Login with with a passkey
Feel free to reach out to us on Discord if you get into any issues.
This project is licensed under the MIT License.