Core & providers
The provider every theme mounts once, the context it shares, and the component registry.
Every theme wraps its pages in one component, TwilightProvider. Everything else in the engine reads from it: the store, the theme settings, the language. This group is that foundation, plus the registry that lets a theme swap a built-in component for its own.
Entries
The component a theme mounts once around its pages; it shares the store, theme, language and navigation with everything inside it.
useTwilightReads everything TwilightProvider knows: store, theme, settings, language, direction, current page, login token and the Salla SDK.
useNavigateReturns a navigate(path) function that moves to another store page from code, without reloading the whole page.
useLocationReads the current address as the router sees it (path, parsed query, raw query, hash), in the server render and in the browser.
useIsHome, useIsProduct…Seven yes-or-no hooks that tell a component which kind of store page is showing: home, product, cart, account, blog, brands or search.
useRouteIdReturns the id of the page on screen, such as "cart" or "product.single", and renders the component again when the shopper navigates.
RouteIdThe named list of every engine page id, so code compares with RouteId.CART instead of typing the string "cart".
registryThe shared name-to-component table the engine consults for a few swappable parts: the product card, the product gallery and home blocks.
ComponentRenders the component registered under a name, passing every other prop to it, or a fallback when nothing is registered there.
useComponentReturn the component registered under a name, or the one it replaced, so you render it yourself with typed props.
defineComponentRegisters a component under a name when its file loads, and returns the same component so it can also be imported and rendered directly.
registerComponents, overrideComponentsRegister or override many named components in one call, from an object whose keys are names and whose values are components.
ComponentRegistryThe class behind registry. A new instance is a private registry that engine components never read, useful in tests and tooling.
notFound, redirect, unauthorizedThrow helpers for route loaders: stop and show the not-found page, send the visitor to another address, or refuse a guest.
orThrow, orUnauthorizedWrap an API call in a loader: orThrow turns any failure into a not-found error, orUnauthorized turns a 401 or 403 into the unauthorized flow.
NotFoundError, RedirectError, UnauthorizedErrorThe error classes behind the loader helpers, so an error screen can tell a missing page, a redirect and a refused guest apart.
SettingsErrorThe error thrown when a request has no store settings; left uncaught at the root it becomes the "Store Unavailable" page.
LinkProviderTells the engine's Link which real anchor component to render; TwilightProvider supplies TanStack Router's, and tests can supply a plain one.
useLinkAdapterReturns the anchor component the nearest LinkProvider supplies, and throws LinkProviderError when there is no provider above.
createLinkWithAdapterBuilds a link component bound to one adapter, which renders without any LinkProvider above it.
NavigationProviderSupplies the function useNavigate() returns to everything below it; TwilightProvider mounts one for TanStack Router, and tests can mount their own.
NavigationInterceptorTurns clicks on ordinary links to this store, including links inside Salla web components, into in-app navigation instead of full reloads.
configureNavigationReplaces what notFound, redirect and unauthorized throw. A framework adapter calls it once; theme code never needs to.
useDocumentClassOutputReturns the merged html and body attributes every useDocumentClass() call has registered, as React props ready to spread.
useDocumentClassContextLow-level access to the store behind useDocumentClass(): register or remove an html and body descriptor under an id you choose.
DocumentClassProviderCollects every useDocumentClass() request in its tree and applies the merged classes and attributes to the real body and html elements.
routeDocumentSyncs, registerDocumentSyncThe per-framework table of components that add route-based body classes, and the function that adds a framework to it.
ProductContextProviderA React context for a product: wrap part of the page once, then read the product anywhere inside it without passing it down.
CartContextProviderA React context for a cart object: wrap part of the page once, then read the cart anywhere inside it with useCartContext().
Also exported here
These exports have no page of their own yet. Their signatures, straight from the engine's type declarations, are in the complete list.
| Export | Kind | Import path |
|---|---|---|
HookName | enum | @salla.sa/twilight-theme-engine |
HookDefinition | interface | @salla.sa/twilight-theme-engine |
HookHandler | type | @salla.sa/twilight-theme-engine |
HookHandlers | type | @salla.sa/twilight-theme-engine |