Documentation

Everything you need to integrate Zautha into your application.

Quick Start

1. Install the SDK

npm install @zautha/sdk @zautha/react

2. Add the Provider

Wrap your application with the ZauthaProvider:

import { ZauthaProvider } from '@zautha/react';

function App({ children }) {
  return (
    <ZauthaProvider projectKey="pk_live_xxx">
      {children}
    </ZauthaProvider>
  );
}

3. Use Authentication

Access authentication state with hooks:

import { useAuth, useUser } from '@zautha/react';

function Dashboard() {
  const { isSignedIn, signOut } = useAuth();
  const { user } = useUser();

  if (!isSignedIn) {
    return <SignIn />;
  }

  return (
    <div>
      <p>Welcome, {user.email}</p>
      <button onClick={signOut}>Sign out</button>
    </div>
  );
}

API Reference

Authentication Endpoints

  • POST /v1/auth/sign-up - Create a new user
  • POST /v1/auth/sign-in - Authenticate a user
  • POST /v1/auth/sign-out - End a session
  • POST /v1/auth/refresh - Refresh access token
  • GET /v1/auth/me - Get current user

OAuth Endpoints

  • GET /v1/auth/oauth/:provider/authorize - Start OAuth flow
  • GET /v1/auth/oauth/callback - OAuth callback

MFA Endpoints

  • POST /v1/auth/mfa/totp/setup - Set up TOTP
  • POST /v1/auth/mfa/totp/verify - Verify TOTP code
  • POST /v1/auth/mfa/verify - Verify MFA challenge

Passkey Endpoints

  • POST /v1/auth/passkey/register/begin - Start passkey registration
  • POST /v1/auth/passkey/register/complete - Complete registration
  • POST /v1/auth/passkey/authenticate/begin - Start passkey auth
  • POST /v1/auth/passkey/authenticate/complete - Complete auth

React SDK Hooks

useAuth()

Access authentication state and methods.

const { isLoaded, isSignedIn, signIn, signOut } = useAuth();

useUser()

Access current user data.

const { user } = useUser();
// user.id, user.email, user.metadata

useSession()

Access current session data.

const { session } = useSession();
// session.id, session.createdAt, session.expiresAt

Need Help?

Check out our GitHub repository for issues, discussions, and more examples.

View on GitHub