Sign In

@authon/svelte

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@authon/svelte

Authon Svelte SDK — stores and components

Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
39
1850%
Maintainers
1
Weekly downloads
 
Created
Source

@authon/svelte

Svelte SDK for Authon — stores, actions, and components.

Install

npm install @authon/svelte
# or
pnpm add @authon/svelte

Requires svelte >= 4.0.0.

Quick Start

1. Initialize

// src/lib/authon.ts
import { initAuthon } from '@authon/svelte';

export const authon = initAuthon({
  publishableKey: 'pk_live_...',
});

2. Use Stores

<script>
  import { user, isSignedIn, isLoading } from '@authon/svelte';
  import { openSignIn, signOut } from '@authon/svelte';
</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}

3. Use Components

<script>
  import { SignedIn, SignedOut, UserButton } from '@authon/svelte';
</script>

<SignedIn>
  <UserButton />
</SignedIn>
<SignedOut>
  <button on:click={openSignIn}>Sign In</button>
</SignedOut>

API Reference

Stores

StoreTypeDescription
userReadable<AuthonUser | null>Current user
isSignedInReadable<boolean>Whether the user is signed in
isLoadingReadable<boolean>Whether auth state is loading

Actions

FunctionReturnsDescription
openSignIn()Promise<void>Open sign-in modal
openSignUp()Promise<void>Open sign-up modal
signOut()Promise<void>Sign out
getToken()string | nullGet current access token

Components

ComponentDescription
<SignedIn>Renders slot only when signed in
<SignedOut>Renders slot only when signed out
<UserButton>Avatar dropdown with sign-out

Documentation

authon.dev/docs

License

MIT

Keywords

authon

FAQs

Package last updated on 03 Mar 2026

Did you know?

Socket

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.

Install

Related posts