All docs pages
Docs

Sign-up and sign-in

Accounts with email and password, a confirmation email, password reset, roles and a members-only switch.

In stackly.json and the CLI it is sign-in. It has no price of its own; see What features cost.

sign-in · optional · needs backend, database, email · D1 and Email Service, run by Stackly's kit

Accounts with email and password, a confirmation email, password reset, email and password changes, login protection, roles, a members-only switch, account export and delete.

Turn it on

"features": ["backend", "database", "email", "sign-in"],
"bindings": ["APP_DATABASE"]

stackly features on sign-in adds what it needs. Add two-factor for authenticator-app codes.

Use it

Build the pages on the server functions in src/lib/auth.ts. Each answers { ok: true, … } or { ok: false, error } with a message to show as it is, so forms need no try/catch.

PageServer functions
/sign-upgetSignUpOpen, signUpFn({ email, password, confirmPassword, profile? }), resendConfirmationFn
/sign-insignInFn({ email, password }) → status: "signed-in" or "two-step-needed"; verifyTwoFactorFn({ code })
/reset-password (?token=)requestPasswordResetFn({ email }), resetPasswordFn({ token, password, confirmPassword })
/accountgetCurrentUser, changePasswordFn, requestEmailChangeFn, updateProfileFn, exportAccountFn, deleteAccountFn, signOutFn

Guard server code, never only the page:

import { requireRole, requireUser } from "#/lib/auth.server";

const user = await requireUser();        // throws when nobody is signed in
const admin = await requireRole("admin"); // throws for other roles
  • Links in the emails land on /api/stackly/auth (confirm, new address); leave that route as it is.
  • Members-only: call getMembersOnlyRedirect from the root route's beforeLoad and redirect when it answers a path.
  • Keep the app's own data in its own tables keyed by the account id, and delete it in the same server function that calls deleteAccount.
  • Tables stackly_users, stackly_sessions, stackly_tokens, stackly_auth_attempts are made on first use. Never write to them directly: Stackly's Users panel reads them.

Owner settings

Declare the ones the app uses with "feature": "sign-in": sign-up-open (boolean, default true), members-only (boolean, default false), default-role (text, default "member"), after-sign-in-path (text, default "/"), password-min-length (number, default 10).

Limits

5 wrong passwords lock an address for 15 minutes; 30 from one network lock that network. Sessions last 30 days. Reset links last 1 hour, confirmation links 24 hours. Messages never say whether an address has an account.

In Stackly

The owner sees accounts on the Users panel of the feature's page, changes roles there, and can turn sign-up off.

Locally

Confirmation and reset emails are not sent from stackly dev: it prints each email with its link, so copy the link from its console. The draft keeps them in the outbox.

Don't

No OAuth providers (Google, GitHub) are offered. For a team tool where visitors need no accounts of their own, suggest private-access instead.

All app features