
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
@authon/svelte
Advanced tools
English | 한국어
Drop-in Svelte authentication with reactive stores — self-hosted Clerk alternative, Auth0 alternative
Before installing the SDK, create an Authon project and get your API keys:
Create a project at Authon Dashboard
Get your API keys from Project Settings → API Keys
pk_live_... or pk_test_...) — safe to use in client-side codesk_live_... or sk_test_...) — server-side only, never expose to clientsConfigure OAuth providers (optional) in Project Settings → OAuth
https://api.authon.dev/v1/auth/oauth/redirectTest vs Live keys: Use
pk_test_...during development. Switch topk_live_...before deploying to production. Test keys use a sandbox environment with no rate limits.
npm install @authon/svelte
<!-- src/routes/+layout.svelte -->
<script lang="ts">
import { initAuthon } from '@authon/svelte';
import { onDestroy } from 'svelte';
const authon = initAuthon('pk_live_YOUR_PUBLISHABLE_KEY', {
apiUrl: 'https://your-authon-server.com',
theme: 'auto',
});
onDestroy(() => authon.destroy());
</script>
<slot />
<!-- src/routes/+page.svelte -->
<script lang="ts">
import { getAuthon } from '@authon/svelte';
const { user, isSignedIn, isLoading, openSignIn, signOut } = getAuthon();
</script>
{#if $isLoading}
<p>Loading...</p>
{:else if $isSignedIn}
<p>Welcome, {$user?.displayName}</p>
<button on:click={signOut}>Sign out</button>
{:else}
<button on:click={openSignIn}>Sign in</button>
{/if}
<script lang="ts">
import { getAuthon } from '@authon/svelte';
const { client } = getAuthon();
</script>
<button on:click={() => client.signInWithOAuth('google')}>Sign in with Google</button>
<!-- src/routes/dashboard/+page.svelte -->
<script lang="ts">
import { getAuthon } from '@authon/svelte';
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
const { isSignedIn, isLoading } = getAuthon();
onMount(() => {
if (!$isLoading && !$isSignedIn) goto('/sign-in');
});
</script>
{#if $isSignedIn}
<h1>Dashboard</h1>
{/if}
<script lang="ts">
import { getAuthon } from '@authon/svelte';
const { user, isLoading } = getAuthon();
</script>
{#if $isLoading}
<p>Loading...</p>
{:else if $user}
<p>Email: {$user.email}</p>
<p>Name: {$user.displayName}</p>
{:else}
<p>Not signed in</p>
{/if}
<script lang="ts">
import { getAuthon } from '@authon/svelte';
const { client } = getAuthon();
let email = '';
let password = '';
async function handleSignIn() {
await client.signInWithEmail(email, password);
}
</script>
<form on:submit|preventDefault={handleSignIn}>
<input bind:value={email} type="email" placeholder="Email" />
<input bind:value={password} type="password" placeholder="Password" />
<button type="submit">Sign in</button>
</form>
<script lang="ts">
import { getAuthon } from '@authon/svelte';
const { signOut } = getAuthon();
</script>
<button on:click={signOut}>Sign Out</button>
| Variable | Required | Description |
|---|---|---|
PUBLIC_AUTHON_API_URL | Yes | Your Authon server URL |
PUBLIC_AUTHON_PUBLISHABLE_KEY | Yes | Project publishable key |
| Function | Description |
|---|---|
initAuthon(key, config?) | Create store and set in Svelte context (call in root layout) |
getAuthon() | Get AuthonStore from context (call in child components) |
createAuthonStore(key, config?) | Low-level store factory (without context) |
| Property / Method | Type |
|---|---|
user | Readable<AuthonUser | null> |
isSignedIn | Readable<boolean> |
isLoading | Readable<boolean> |
client | Authon |
signOut() | Promise<void> |
openSignIn() | Promise<void> |
openSignUp() | Promise<void> |
getToken() | string | null |
web3GetNonce(...) | Web3 nonce request |
web3Verify(...) | Web3 sign-in |
passwordlessSendCode(...) | Send magic link or OTP |
passwordlessVerifyCode(...) | Verify OTP |
passkeyRegister(...) | Register passkey |
passkeyAuthenticate(...) | Auth with passkey |
destroy() | Cleanup |
| Feature | Authon | Clerk | Auth.js |
|---|---|---|---|
| Self-hosted | Yes | No | Partial |
| Pricing | Free | $25/mo+ | Free |
| OAuth providers | 10+ | 20+ | 80+ |
| ShadowDOM modal | Yes | No | No |
| MFA/Passkeys | Yes | Yes | Plugin |
| Web3 auth | Yes | No | No |
MIT
FAQs
Authon Svelte SDK — stores and components
The npm package @authon/svelte receives a total of 31 weekly downloads. As such, @authon/svelte popularity was classified as not popular.
We found that @authon/svelte demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.