AutherBeta

Quick Start

Get Auther running in your app in under 5 minutes - frontend auth modal and a protected backend route.

1

Create a project & grab your keys

Sign in to the Auther dashboard and create a project. Your Client Secret is shown once, right after the project is created: copy it then and store it somewhere safe.

We only keep a hash of it, so nobody can show it to you again, us included. Your Client ID is not a secret and stays visible under API Keys at any time. If you lose the secret, revoke the key there and generate a new one.

2

Install the packages

bash
# React / Next.js - use the React SDK (includes frontend SDK)
npm install @auther-sdk/react

# Vanilla JS / any other framework
npm install @auther-sdk/frontend

# Your server / API
npm install @auther-sdk/node
3

Add auth to your app

React / Next.js - wrap your app in <AutherProvider>:

tsx
import { AutherProvider } from '@auther-sdk/react';

export default function Layout({ children }) {
  return (
    <AutherProvider
      clientId="req_live_xxxxxxxxxxxxxxxx"
      endpoint="https://your-auther-endpoint/api/v1"
    >
      {children}
    </AutherProvider>
  );
}

// In any component:
import { useAuther } from '@auther-sdk/react';

function Navbar() {
  const { user, login, logout } = useAuther();
  return user
    ? <button onClick={logout}>Log out</button>
    : <button onClick={login}>Log in</button>;
}

Vanilla JS - call init() once on page load:

typescript
import Auther from '@auther-sdk/frontend';

Auther.init({
  clientId: 'req_live_xxxxxxxxxxxxxxxx',
  onAuth: (user) => {
    if (user) loadApp(user);
    else showLanding();
  },
});

Auther.mount('#login-btn');
4

Protect a route on your server

typescript
import express from 'express';
import cookieParser from 'cookie-parser';
import { Auther } from '@auther-sdk/node';

const app    = express();
const auther = new Auther({
  clientId:     'req_live_xxxxxxxxxxxxxxxx',
  clientSecret: 'sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
});

app.use(express.json());
app.use(cookieParser());

app.get('/me', auther.protect(), (req, res) => {
  res.json({ user: req.autherUser });
});

app.listen(3001);

That's it

Your users can now sign up, log in, and your backend verifies their identity on every request. Token rotation and refresh happen automatically.