New:Socket for Asana Is Now Available.Learn more
Sign In

@authon/svelte

Package Overview
Dependencies
Maintainers
1
Versions
15
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.1.16
Version published
Maintainers
1
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 23 Feb 2026

Related posts