Accounts
Site accounts for a site's visitors, such as a shop's buyers or a client area's members, who sign up, sign in and look after their own account, and never reach the admin.
Experimental.
Everything
@nextlyhq/plugin-accountsexports is@experimental. The stability boundary is@nextlyhq/plugin-sdk(see API stability); this package's own exports are outside it and may change between alpha releases. Pin your versions and read the release notes before upgrading.
The accounts plugin gives a site accounts for its visitors: they sign up, verify their address, sign in and look after their own account. A site account is its own kind of signed-in person, never a staff user, so it can never reach the admin. Staff see and manage the accounts from the admin.
Installation
npm install @nextlyhq/plugin-accountsIts peer dependency is nextly, pinned at the matching lockstep version: install the plugin
and the core at the same version. next and react are optional peers, needed only for the
@nextlyhq/plugin-accounts/next entry.
Basic setup
import { defineConfig } from "nextly";
import { accounts } from "@nextlyhq/plugin-accounts";
export default defineConfig({
plugins: [accounts({ origin: "https://example.com" })],
});origin is the site's own address, which every link in an email is built on. The plugin keeps
its records in collections it adds: run nextly migrate:create and nextly migrate after
installing it.
What it offers
- Typed server functions for every action a visitor takes, from
accountsServer(), and the same functions for another plugin throughaccountsServices(ctx). - REST endpoints for the same actions, behind the plugin's origin and CSRF checks.
- Next.js server actions that work before JavaScript loads, and
requireAccount()for server components, from@nextlyhq/plugin-accounts/next. - Closing sign-up (
signUp: "closed") and invitations issued by the site's own code, for sites where only the people it chooses have accounts. - Ending access from the site's own code: ending an account's sessions, and deactivating and reactivating it, each recorded in the audit log.
The package's README lists every option, function and error code.
MCP
A Model Context Protocol endpoint for AI agents, off by default, that reads review state and submits for review as the key it is given, and approves and publishes nothing.
Commerce
A catalogue to sell from, a cart kept on the server behind a cookie, and a checkout that turns it into an order and starts its payment, with the REST routes and typed server functions a storefront uses.