Quick Start
import { Steps } from ‘@astrojs/starlight/components’;
This guide walks through the minimal integration. By the end, your users will be able to log in through a SpartanAuth-powered widget and your backend will be able to verify their identity.
Signup already created your tenant root (the organization) and an app sector named My first app. The slug is how you open the dashboard. The Sector ID on the signup page belongs to the organization. The login widget needs the My first app Sector ID, which the dashboard selects for you. See Tenant root and app sectors.
-
Use My first app
Open the invite email, set your password, and sign in at
https://dashboard.spartanauth.com/login/{your-slug}. That account is the organization admin.The home card has My first app selected. Set that app’s Domain or Allowed Origins, then copy its Sector ID for the next step. Do not point the widget at the organization Sector ID from signup.
To add another product later, open Sectors and choose New sub-sector. You can rename My first app in Settings. Its slug stays fixed.
-
Add the login widget to your frontend
Install the widgets package:
Terminal window npm install @masonitestudios/spartanauth-widgetsImport it once in your app’s entry point:
import '@masonitestudios/spartanauth-widgets';Add the login widget wherever you want the login form:
<spartan-logindomain="https://api.spartanauth.com"sector="YOUR_SECTOR_ID"start-mode="password"redirect="/app"></spartan-login>Replace
YOUR_SECTOR_IDwith the ID you copied from the dashboard. When a user logs in successfully, they’ll be redirected to/appand a JWT will be stored inlocalStorage['spartan-token']. -
Verify tokens in your backend
When your frontend makes an API call, it sends the JWT in the
Authorizationheader:Authorization: Bearer <token>Your backend verifies it by calling the introspection endpoint:
Terminal window curl -X POST https://api.spartanauth.com/api/v1/introspect \-H "Content-Type: application/json" \-d '{"token": "<jwt>"}'A valid token returns HTTP 200 with the user’s identity:
{"sub": "3f2a8c1d-...","username": "user@example.com","sectorID": "a1b2c3d4-...","isAdmin": false,"exp": "1717000000","iat": "1716996400"}An invalid or expired token returns HTTP 401. A token for a different app sector still returns HTTP 200, so the check also compares
sectorID. See the Go, Node.js, or Python example.
What’s next?
Section titled “What’s next?”- Frontend framework: See the Vue 3, React, or Vanilla JS integration guides.
- All widget options: Check the Widgets Reference for the full attribute and event API.
- Protecting routes with Traefik: See Traefik ForwardAuth.
- Let users manage their account: Add the
<spartan-account-settings>widget to your app.