SimpleAuth

Getting started

Create an app, install the SDK, and authenticate your first user.

Using React or Next.js?

Jump straight to the React quick start to scaffold hooks, forms, and modals with one command. This page walks through the framework-agnostic JavaScript SDK.

1. Create an app

Sign in to the SimpleAuth dashboard and create a new application. You will get two API keys:

  • Public key (sa_live_…) — safe to ship in browsers and mobile clients.
  • Secret key (sa_secret_…) — backend only. Never expose this in client code.

2. Install

Pick the starting point that matches your stack.

npm install @simpleauthjs/core

Continue with step 3 below.

npx @simpleauthjs/react init

The CLI installs @simpleauthjs/core and scaffolds a typed client, SimpleAuthProvider, hooks, and UI components into components/simpleauth/ — all files you own and can edit.

Head to the React quick start for the rest of the flow.

3. Initialize the client

import { createSimpleAuthClient } from "@simpleauthjs/core"

const auth = createSimpleAuthClient({
  apiKey: "sa_live_…",
})

4. Register and sign in a user

await auth.register({
  email: "user@example.com",
  password: "s3cureP@ssword",
  name: "Jane Doe",
})

await auth.login({
  email: "user@example.com",
  password: "s3cureP@ssword",
})

const { user } = await auth.me()
console.log(user.email)

Sessions are managed with HTTP-only cookies automatically — no tokens to store.

5. Sign out

await auth.logout()

Next steps

On this page