The `Context` object is the foundational state container that powers all page generation, controller execution, collection resolution, and rendering behavior within Rift SSG. It is the central interface that ties together project-wide data, localized configuration, collection access, and page scheduling.
The `Context` object is an encapsulated representation of the current state during a build step. It is passed into every user-facing function in the Rift pipeline, including:
params(context) in controller filespermalink(context) in routing logiccollection(context) in collection API loadersrender(context, data) in the rendering stageInternally, the context object includes:
context.param(...)Understanding how context lives and mutates during different build phases is key to using it effectively.
params(context)In this phase, the context is shared and mutable. You typically use this to scan collections, derive which pages should exist, and use context.param() to register page variants.
permalink(context)For each set of parameters declared earlier, a new context is created using .makeChildContext(). This ensures clean page-by-page logic, and allows you to derive a URL (permalink) from that page's localized state.
render(context, data)At this phase, the context is read-only from the user’s perspective. It contains everything required to render the page: the params, locale, associated layout, and any project-global metadata.
One of Rift’s core features is built-in i18n, and the context object plays a central role in this. During all phases, context.locale tells you which locale is currently being processed — for example, "en" or "fr".
The context object gives access to all declared collections via context.collections, which is typically a Map<string, Collection>. These are automatically loaded during the initialization step of the build.
The most important context method during params(context) is:
context.param(paramsObject) — This tells Rift: “I want to generate a page for this set of parameters.”Because context includes a mutable data object, you can store scoped variables inside it during params() execution and use them across multiple passes.
context.locale inside controllers to avoid cross-language leaks.context as read-write during params(), and read-only during render().