@selorax/runtime
v0.1.17
Published
> The multi-tenant Next.js renderer for the **SeloraX Pages** platform — the engine that turns a tenant's HTML/TSX project into a served storefront.
Downloads
2,013
Readme
@selorax/runtime
The multi-tenant Next.js renderer for the SeloraX Pages platform — the engine that turns a tenant's HTML/TSX project into a served storefront.
npm i @selorax/runtime0.1.0 · pre-1.0. Peer deps: next@16, react@19, react-dom@19, plus @selorax/data + @selorax/platform.
What it is
Every SeloraX Pages tenant is a Next-app-router-shaped project of files (routes/, components/, partials/, _layout.*). @selorax/runtime is the shared engine that resolves a request to the right file, compiles/loads it, fetches its data, composes layouts, and renders it — with platform islands hydrating in the browser.
You rarely install this by hand. It's emitted into a self-hostable Next app by selorax-pages build and consumed via transpilePackages. This README is for understanding it (or hand-assembling a runtime).
How it works — the SourceProvider seam
One render core, three sources, selected by the SX_SOURCE env var:
| SX_SOURCE | Provider | Where source comes from |
|---|---|---|
| hosted (default) | HostedProvider | the backend + R2 (the platform's own hosting) |
| local | LocalProvider | a project folder, compiled on the fly (selorax-pages dev) |
| prebuilt | PrebuiltProvider | a precompiled manifest + artifacts (selorax-pages build output) |
The render core (JIT loader, layout composition, templating, data loaders) and the platform islands are shared and source-agnostic — only the provider + tenant/auth context differ.
Exports
import { CatchAll, RootLayout, getProvider, getTenantContext,
cartEnrichPOST, checkoutPOST, ordersModifyPOST } from '@selorax/runtime';
import '@selorax/runtime/client'; // re-exports the platform islands for the client bundle
// '@selorax/runtime/cart-sdk' → the built /selorax-cart.js (mounts window.SeloraX.cart).—CatchAll(the[[...slug]]page),RootLayout, the provider/context helpers, and the commerce API route POST handlers../client— the platform islands, re-exported so Next bundles them../cart-sdk— the cart SDK script asset.
Notes
- Next.js 16 (App Router, Turbopack) — not the Next you may remember (async
params/headers(),serverExternalPackages, etc.). @selorax/data+@selorax/platformare peer dependencies — the consuming app provides them.@selorax/compileris only needed inlocal(dev) mode;LocalProviderlazy-requires it, soprebuilt/hostednever load it.- In local dev (
SX_SOURCE=local) the data cache is bypassed and--watchenables SSE live-reload.
Part of SeloraX Pages
@selorax/data · @selorax/runtime · @selorax/platform · @selorax/compiler · @selorax/pages-cli
