Next.js

Compose Playstack server contracts, React bindings, SSR handoff, and route adapters at the Next.js application edge.

Visit Next.js ↗

Supported features

Authentication

Compose credentials, magic links, sessions, passkeys, MFA, and connected-provider access without handing application identity to a framework.

Email and password · Magic links · Sessions · Split-origin browser sessions · Auth.js provider sign-in · OAuth connections

Accounts and tenancy

Model organizations, memberships, invitations, ownership, active-account switching, and fail-closed data scope.

Invitations · Active-account switching

Email delivery

Render typed application email and deliver it through explicit SES, Mailgun, Postmark, Resend, SendGrid, SMTP, or capture-test providers.

Rendered application email

Events and workflows

Carry typed domain events, operation context, transactional delivery, and replay-safe processing across application boundaries.

Background jobs and workflows

Feeds and syndication

Publish RSS, Atom, JSON Feed, sitemaps, and related discovery surfaces from portable feed contracts.

RSS, Atom, and JSON Feed · Sitemaps and discovery

Analytics

Collect consent-aware application events and deliver them through explicit browser and server boundaries.

Browser analytics

Connections

Authorize, encrypt, refresh, and revoke third-party credentials without moving provider APIs or product workflows into a generic abstraction.

OAuth connections · AT Protocol sessions

Devices and trusted sessions

Register application devices, manage push destinations, establish bounded trust, and revoke device-backed access from one explicit identity boundary.

Device registration and inventory · Trusted-device sessions

Client authentication

Authenticate browser extensions, CLIs, desktop apps, and mobile clients through system-browser authorization, PKCE, rotation, and device-aware revocation.

Authorization code with PKCE · Native and extension callbacks · Token rotation and revocation

Device pairing

Establish same-user peer trust across mobile, desktop, and extension surfaces through a versioned protocol with selectable discovery and transport profiles.

Peer trust establishment · Transport profiles

Browser extensions

Build Playstack-connected browser extensions with MV3-safe runtime state, typed messaging, portable storage, and system-browser authentication.

Extension authentication

Notifications and delivery

Define typed notifications, resolve recipient preferences, deliver across explicit channels, and retain one provider-independent history of every send.

Typed notification definitions · In-app inbox

Audiences and subscriber lifecycle

Build waitlists, newsletters, release lists, and preference centers with explicit consent, segmentation, confirmation, and delivery boundaries.

Subscription lifecycle

Content and AI

Model portable content operations and compose AI-assisted generation through explicit providers, schemas, policy, and application-owned publication workflows.

Content contracts · Structured AI generation · Content workflows

Caching

Use namespaced portable caches with typed serialization, tag invalidation, and explicit stampede-protection capabilities across Redis, Workers, and local runtimes.

Namespaced key-value caching · Stampede-protected remember · Tag invalidation

File storage

Store and retrieve application objects through explicit filesystem, S3, or R2 providers with validated keys, metadata, streaming bodies, and signed access.

Portable object storage · Signed download and upload access · Local and test storage

Search

Build product-specific search on portable query, ranking, transport, and framework contracts without coupling records to a provider.

Weighted lexical search · MiniSearch indexing · Next and Nest bindings

Local-first

Share durable local mutations and synchronization semantics across web, Expo, and desktop clients while keeping product policy explicit.

Atomic local mutations · Portable synchronization · Platform storage

Webhooks

Verify provider requests from raw bytes, claim events transactionally, enqueue normalized work exactly once, and keep provider parsing outside domain handlers.

Raw-request verification · Provider normalization

Error handling

Carry stable application errors across server and client boundaries, report normalized failures, and retain framework-native recovery without leaking sensitive context.

Stable application errors · React recovery boundaries · Provider-independent reporting

Realtime and WebRTC

Compose authenticated realtime channels, resumable client state, WebRTC session control, and ICE or relay infrastructure without conflating events, signalling, and media.

Authenticated realtime channels · WebRTC sessions and signalling

Progressive web apps

Compose installability, application-shell caching, update coordination, and push registration without confusing a service worker with local-first application data.

Manifest and installation · Application-shell caching · Safe update coordination · Web Push registration

Application interfaces

Compose application-owned React and Next surfaces from Chakra themes, controlled App UI and initial admin sections.

Prebuilt and custom administration

Localization

Share locale policy and message catalogs across application UI, APIs and delivery without choosing a translation vendor.

UI and API composition

Package reference

@playstack/i18n-react

Install the edges you use

Next.js can host browser UI, server rendering, route handlers, and application composition. Playstack adapters describe the router and runtime boundary they actually support instead of claiming every Next.js surface implicitly.

sh
npm install @playstack/auth @playstack/auth-next @playstack/auth-react
Next.js boundaryPlaystack packageResponsibility
Browser providers and forms@playstack/auth-reactSafe session state and application-owned auth transport
Pages Router SSR@playstack/auth-nextOptional or required session handoff
App Router server components and route handlers@playstack/auth-nextValidated session resolution and application-owned unauthenticated policy
App Router content lookup@playstack/content-nextStatic params and document lookup with direct or promised route params
Shared ISR and signed revalidation@playstack/cache-nextRedis-backed cache handling, tag invalidation, and router-specific revalidation
App and Pages Router search@playstack/search-nextValidated search handlers with explicit request context and cache policy
API route or route handler@playstack/authPortable credential and session authority composed by the application
App Router feed route@playstack/feeds-nextFeed and sitemap response adapters
Navigation analytics@playstack/analytics-reactExplicit Pages and App Router navigation adapters
Audience forms and preferences@playstack/audiences-reactHeadless signup and token-scoped preference state
Notification inbox@playstack/notifications-reactHeadless inbox, pagination, unread state, and optimistic mutations

Connect the browser to application routes

tsx
import { PlaystackAuthProvider, createFetchAuthTransport } from '@playstack/auth-react'

const transport = createFetchAuthTransport({
  sessionEndpoint: '/api/auth/session',
  refreshEndpoint: '/api/auth/refresh',
  signInEndpoint: '/api/auth/sign-in',
  signOutEndpoint: '/api/auth/sign-out',
  headers: () => ({ 'x-csrf-token': readCsrfCookie() }),
})

export function ApplicationProviders({ children, session }) {
  return (
    <PlaystackAuthProvider transport={transport} initialSession={session}>
      {children}
    </PlaystackAuthProvider>
  )
}

Those four routes belong to the application. They translate HTTP and cookies into calls to the configured portable auth service, validate CSRF where cookies are ambient, and return only AuthSessionView. When the API is a separate origin, use createBearerAuthTransport with the API's baseUrl and drop the CSRF header: the API answers { session, accessToken, accessExpiresAt } and protects its cookie routes with Origin and Sec-Fetch-Site checks for browser requests (PlaystackOriginGuard in @playstack/nest-auth), while non-browser clients reach the same routes with a bearer token.

Compose SSR session handoff

ts
import { createAuthNextHelpers } from '@playstack/auth-next/pages'

export const { requireSession, withSession } = createAuthNextHelpers({
  resolveSession: ({ req }) => resolveSafeSessionView(req),
})

Hydrate the same validated session into PlaystackAuthProvider for client navigation without an unauthenticated flash.

Choose the router boundary explicitly

For a Pages Router page, use withSession when authentication is optional and requireSession when the page must redirect before rendering.

For an App Router application, create helpers from @playstack/auth-next/app. The resolver still belongs in a server-only application module, while Next's redirect() or a route-handler response is supplied as the explicit unauthenticated boundary. This supports Server Components and route handlers without hiding cookie access, cache policy, middleware, or server-action authorization.

tsx
import { redirect } from 'next/navigation'

import { createAppRouterAuthHelpers } from '@playstack/auth-next/app'

const auth = createAppRouterAuthHelpers({
  resolveSession: () => resolveSessionViewFromCookies(),
})

export default async function AccountPage() {
  const session = await auth.requireSession({
    redirectTo: '/login',
    onUnauthenticated: (destination) => redirect(destination ?? '/login'),
  })

  return <Account userId={session.user.id} />
}

Provider sign-in follows the same rule. Auth.js may own its provider handshake while @playstack/auth-authjs normalizes the callback into Playstack identity policy. Email/password and magic-link routes can call the portable credential service directly. See the Authentication feature guide to choose the entry path.

Add capabilities independently

Account switching adds @playstack/accounts-react; feeds and sitemaps add @playstack/feeds-next. Shared ISR adds @playstack/cache-next, while search routes can use @playstack/search-next independently of either. None requires rebuilding the authentication boundary. Follow each supported feature above to see its frontend, server, persistence, and provider dependencies.

Router boundaries

Auth, content, search, and cache adapters publish explicit router boundaries where their contracts differ. Analytics publishes ./next-pages and ./next-app, while feeds produces App Router-compatible route handlers. Provider SDKs, cookies, redirects, cache policy, environment loading, and database clients remain in the application composition root.

Application UI compositions

The optional UI stack now includes Chakra themes, app shells/navigation, settings, tables, commands, Kanban and resizable panes, plus the first account-admin shell and members section. These are React DOM compositions, separate from the headless domain bindings.

Prebuilt and custom Next routes use an application-owned shell and server authorization. Create Chakra systems in client-owned modules; keep interactive callbacks behind Client Component boundaries. Global staff and impersonation flows are still to come; verify browser behavior in your own product. See UI packages.

Localized UI without another router

Use i18n-react for shared App UI/Admin UI catalogs, or compose its message provider alongside the application's existing locale library. Keep SSR/client locale, time zone and direction consistent. Playstack does not install a locale router or ICU runtime. See UI localization.

Go

Playstack Pro tag
OriginsPricingBlogNewsletterChangelogStatusRoadmap
ContributorsCommunityIn Use ShowcaseCase StudiesPartnersSponsors
FAQsSupportContact

© 2026 Playstack. All rights reserved.

With OSS
Terms of ServicePrivacy PolicyCookie PolicyImprint

By

Commune Software