Developers · Pages and Layouts
Context Variable
Last updated 2 November 2026
The
Inspecting the Context Object
During development, you can output the entire context object on a page to inspect its structure:
---
slug: debug
---
{{ context }}Context Components
context.params
Contains all HTTP request parameters, including URL query strings, form data, and named route parameters. For example,
context.current_user
Returns the currently logged-in user's basic data:
context.session
A key-value store for the current user's session. Use it to persist data across requests (e.g., shopping cart contents, wizard progress). Set values with the
context.constants
Provides access to sensitive data like API keys, tokens, and secrets. Constants are hidden from
context.location
Contains information about the current URL:
- full URL of the current request - domain name - URL path without query string - query string
context.headers
Contains HTTP request headers. Use this to check content types, authorization tokens, or custom headers sent by the client.
context.page
Contains information about the current page, including its metadata. Access custom metadata via
context.environment
Returns the current environment type. Use this to conditionally render content or enable features based on whether you are on staging or production.
context.authenticity_token
The CSRF token populated by the server. Include it in all non-GET form submissions to prevent cross-site request forgery attacks. It is automatically included when using the form tag.
context.cookies
Returns an object containing all cookies for the current site.
context.device
Returns information about the visitor's device, including device type detection (mobile, tablet, desktop).
context.flash
Contains flash messages set during form submissions or redirects. Flash messages persist for one request and commonly show success or error notifications.
context.is_xhr
Returns
context.language
Returns the current language code for the request. Used with the translation system to determine which language to render.
context.modules
Provides access to installed module information.
context.useragent
Returns the raw User-Agent string from the request headers.
context.visitor
Returns visitor-level information, typically used for analytics and tracking.