Insites Docs Developers liquid Objects: platformOS

Objects: platformOS

Last updated on October 22, 2025

context

The object is a global object encountered and used across platformOS. Its scope is universal, making it accessible in every Liquid component, including pages, partials, and layouts, and Email, SMS, and API Call Notifications. Crucially, is the only pre-defined object available, as the platform is designed to allow you to build and define all other custom objects required by your application.

This section discusses the following topics:

context.authenticity_token

is populated by the server and automatically included in every form generated by the tag. It is used to mitigate Cross Site Request Forgery attacks, and must be added to the payload in all server requests other than .

context.constants

provides access to sensitive data like API credentials and tokens. To protect you from accidentally leaking this information, you need to call explicitly, as these values are hidden from by default. You can set constants using the GraphQL mutation or via the .

context.cookies

returns an object with all the cookies of the site.

context.current_user

returns the basic data of the currently logged-in user and returns instead of an object if no user is logged in. Its available attributes are:

context.device

returns a hash with useful information based on . Most notably, returns one of the following:

context.environment

returns one of the following strings:

A common use case for this object is hiding certain functionalities in production without blocking the release.

context.flash

returns an object with the following keys:

The value for each key is a message string. Flash messages are set on form submissions.

context.headers

contains allowed HTTP headers with the data from the current HTTP request.

Available headers are:

context.is_xhr

returns the following values:

  • : for non-XHR requests
  • : for XHR requests

An XHR request is identified by checking if the value of the header matches .

context.language

returns a , the language ISO code used in the current request. For more information about the built-in translation mechanism, please visit Translations.

context.location

contains URL data of current request. Available attributes are:

Example 1: Extracting params from path name

This example extracts parameters from the path name using .

Sample URL:

Example 2: Conditional list class

context.modules

retrieves information about the version and subscription status of installed modules.

Example: List all properties for installed modules

context.page

contains information about the page where the object is included.

Available attributes:

context.params

contains user data provided in forms and query params. The most common use cases are:

  • Including form data in notifications
  • Form data manipulation through
  • Data validation in authorization policies

Example: site path params mapping

When visiting the page with path the value of would be:

Please note that another way that you can use to extract page parameters is by using Example 1 of context.location.pathname.

context.session

allows for quick access to session storage. Use mutations to store data in a session similar to this example.

A browser initiates a session by generating a unique , stored as a cookie and included with every request sent to the server. The server uses the aforementioned Session ID to retrieve associated JSON data, which is essential for tracking user state. This state can include a for authenticated users, or non-personal data like to power a guest's shopping cart. The session ends when the server automatically invalidates the stored data after a timeout, or if the user manually deletes the cookie, which prompts the creation of a new session.

context.useragent

returns an object with the user agent's data.

Example: Displaying useragent

Result:

context.visitor

returns an object describing the browser user. There is currently only one available attribute: .

Exposing a local variable within the context object

To broaden the scope of a defined local variable, making it accessible outside its current file, you must promote it to the global namespace. Use the tag to perform this operation, as demonstrated in the following example:

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.