Frontend Integration
Svelte
Learn how to add the Corbado web-js package to your Svelte or SvelteKit application.
1. Prerequisites
First, you need to set up a Corbado project.
To get started with the integration, install the Corbado web-js package.
npm install @corbado/web-js
Further information on web-js can be found here
2. Add web-js to Svelte code
+page.svelte
<script lang="ts">
import Corbado from "@corbado/web-js";
import { onMount } from "svelte";
onMount(async() => {
await Corbado.load({
projectId: <CORBADO_PROJECT_ID>,
darkMode: "off",
});
const authElement = document.getElementById("corbado-auth");
Corbado.mountAuthUI(authElement!, {
onLoggedIn: () => {
window.location.href = "/profile";
},
isDevMode: true,
});
});
</script>
<div id="corbado-auth"></div>
If you need access to user data on the server, also take a look at our Corbado Node.js SDK.
3. Read the blog post
To find a step-by-step tutorial on how to integrate passkeys into Svelte, please check out our blog post: