SolidJS & Passkeys: Enhance your SolidJS apps with passkeys. Follow this tutorial to seamlessly integrate Corbado's web-JS for secure logins.
Amal
Created: July 30, 2024
Updated: September 3, 2024
We aim to make the Internet a safer place using passkeys. That's why we want to support developers with tutorials on how to implement passkeys.
5.1 Set Up your Corbado Account and Project
In this blog post, we will guide you through the process of creating a SolidJS application with passkey login functionality using the Corbado web-js component. SolidJS is a reactive UI library that offers excellent performance and reactivity, and Corbado provides a seamless way to integrate passkey authentication into your web applications. We will cover how to embed Corbado's UI components and implement secure login functionality.
If you want to see the complete code, check out our sample SolidJS passkey application repository on GitHub.
Here's a preview of the final passkey login interface with SolidJS:
This tutorial assumes you have a basic understanding of SolidJS, HTML, CSS, and JavaScript. To get started, make sure you have Node.js and npm installed on your machine.
For this example, we'll be using the latest version of SolidJS. Let's start building our secure passkey login application!
Subscribe to our Passkeys Substack for the latest news, insights and strategies.
SubscribeLet's take a closer look at the structure of our repository (full SolidJS passkeys GitHub repository). This structure will help us organize our SolidJS application efficiently, making it easier to manage and scale.
. ├── .env ├── index.html ├── package.json └── src ├── assets ├── components │ ├── Auth │ │ ├── Auth.jsx │ │ └── Auth.module.css │ ├── Profile │ │ ├── Profile.jsx │ │ └── Profile.module.css │ ├── App.jsx │ └── App.module.css ├── index.css ├── index.jsx
Here's a brief explanation of the relevant files and directories:
src/
: The main source directory for our application.
components/
: Contains all the components used in the application.
Auth/
: Contains the Auth.jsx
component and its corresponding CSS module (Auth.module.css
). This component handles the authentication UI.
Profile/
: Contains the Profile.jsx
component and its corresponding CSS module (Profile.module.css
). This component displays the user profile and logout functionality.
App.jsx
: The main application component that sets up routing and renders other components.
App.module.css
: CSS module for styling the App.jsx component.
index.jsx
: The entry point of the application. It initializes and renders the root component.
.env
: Environment variables for configuring the application.
index.html
: The main HTML file for the application.
Become part of our Passkeys Community for updates and support.
JoinIn this section, we'll explain step-by-step how to set up the SolidJS project.
Let's get started by initializing a new SolidJS project:
Next, install the necessary dependencies:
To start the development server and see the basic skeleton of your application, run:
Your application will start at http://localhost:3000
. You should now see the basic structure of your SolidJS alication.
In order to integrate the Corbado's UI components in your SolidJS application, you need to follow these steps.
Visit the Corbado developer panel to sign up and create your account. You'll experience the passkey sign-up in action here!
In the project setup wizard, begin by selecting an appropriate name for your project. For the product selection, opt for "Corbado Complete". Subsequently, select "DEV environment" along with "Corbado session management" options. Afterwards, you'll get more foundational setup guidance.
Next, choose "Web app" as an application type and Vanilla as your frontend framework (as SolidJS supports JavaScript, we can use the VanillaJS UI components). In the application settings, define your Application URL and Relying Party ID as follows:
Application URL: Provide the URL where you embedded the UI component, here: http://localhost:3000
Relying Party ID: Provide the domain (no protocol, no port, and no path) where passkeys should be bound to, here: localhost
Lastly, navigate to the Corbado project settings to find your project ID under Corbado API access. Then, store the project ID in your environment file.
Your environment file should look like this:
You'll need this project ID later to embed the Corbado UI component in your SolidJS app.
To get started with embedding the Corbado UI component in your SolidJS frontend, follow these steps:
Auth
Component:The Auth
component will handle user authentication by embedding Corbado's UI component.
Here’s the complete code of the Auth
component:
App
Component:Configure the App
component to use the Auth
component for the root path and the Profile
component for the /profile
path.
Here’s the complete code of the App
component:
The Profile
component will fetch and display user information using Corbado's API. It will also provide a UI for managing passkeys and logging out.
Here’s the complete code of the Profile
component:
Now, when you start your development server with
and navigate to http://localhost:3000
, you should see the authentication UI.
Once logged in, you'll be redirected to the profile page displaying user details and passkey list feature.
In this tutorial, we've covered how to set up a SolidJS application with Corbado’s web-js component for passkey authentication. This includes initializing a SolidJS project, integrating Corbado for authentication, and creating a profile page with logout functionality. With these steps, you should have a functional passkey login system in your SolidJS application.
Besides the passkey-first authentication, Corbado provides simple session management, that we used for a retrieval of basic user data. If you want to read more about how Corbado's session management please check the docs here.
Table of Contents
Enjoyed this read?
🤝 Join our Passkeys Community
Share passkeys implementation tips and get support to free the world from passwords.
🚀 Subscribe to Substack
Get the latest news, strategies, and insights about passkeys sent straight to your inbox.
We provide UI components, SDKs and guides to help you add passkeys to your app in <1 hour
Start for free
Recent Articles