Page
This page describes all of the page, offer and add-on methods available within the Limio SDK.
The useCampaign hook is part of the Limio SDK and is used to retrieve metadata and commerce objects associated with a Page (formerly called a Campaign). Pages in Limio act as containers for Offers and optional Add-Ons, and can store custom attributes that drive content, logic, or display behaviour on pricing, product, or checkout pages.
This hook allows developers to dynamically access:
Page details, such as the name and custom attributes
Offers, which are subscription products associated with the page
Add-ons, such as optional products or upsells tied to an offer
Tags, used for tracking how users enter a page
These capabilities allow developers to build rich, dynamic storefronts that respond to user context and page configuration. This page provides examples of each method available through useCampaign, along with sample data and common use cases.
useCampaign - Retrieving details of the current page
useCampaign - Retrieving details of the current pageYou may store details about your page (previously called campaign) in custom attributes or if you just want to retrieve the name of the page, the const campaign returns all of these to be used for any case you need.
import { useCampaign } from "@limio/sdk"
const Component = () => {
const { campaign } = useCampaign()
return (
<section>
<h1>{campaign.name}</h1>
// This can be one you configure
<p>{campaign.attributes.custom_attribute}</p>
</section>
)
}Example page:
useCampaign - Retrieving offers of the current page
useCampaign - Retrieving offers of the current pageThe offers return an array of all offers stored under the current page. These are the items that should be used when adding items to the basket with the addToBasket method.
Example offer:
useCampaign - Retrieving add-ons of the current page
useCampaign - Retrieving add-ons of the current pageIf you need to get the add-ons attached to a page, the const addOns returns an array with the add-ons objects:
Example of an add-on:
useCampaign - Retrieving the tag the user entered the page with
useCampaign - Retrieving the tag the user entered the page withIf you need to get the tag that a user entered the page with (useful for tracking), the const tag returns that as a string:
useCampaign - Retrieving group values of the current offers on the page
useCampaign - Retrieving group values of the current offers on the pageGroup values are configured at the offer level. For example, you might want to group offers by values such as monthly, yearly, or a custom value that you configure.

Example of group values:
groupOffers – Grouping offers by label
groupOffers – Grouping offers by labelThe groupOffers function is used to organise a list of offers into groups based on their group__limio attribute. This function is particularly useful when you need to display offers categorised by their group in a component, such as a Switch component.
Function Signature
Parameters
offers(optional): An array ofLimioObject<Offer>objects to be grouped.Type:
Array<LimioObject<Offer>>Default:
[]
groupLabels(optional): An array ofGroupobjects that define the possible groups and their labels.Type:
Array<{ id: string, label: string, thumbnail?: string }>Default:
[]
LimioObject Structure
The LimioObject<Offer> type represents an offer in the Limio system. It has the following structure:
Key points about LimioObject<Offer>:
The
group__limioattribute is used for grouping offers.The
display_name__limioattribute typically contains the display name of the offer.There may be other attributes and properties specific to offers that are not used by the
groupOffersfunction.
Return Value
The function returns an array of GroupInfo objects, where each object contains:
groupId: The identifier of the group (string)id: The same asgroupId(string)label: The display label for the group (string)offers: An array ofLimioObject<Offer>objects belonging to that groupthumbnail: The thumbnail URL for the group (string, optional)
Usage Example
Behaviour Notes
Offers are grouped based on their
group__limioattribute.If an offer doesn't have a
group__limioattribute, it's grouped under "other".For each unique group (including "other"), a
GroupInfoobject is created.If a matching
groupLabelis found:The
labelis set to the matching group's label.The
thumbnailis set to the matching group's thumbnail (or an empty string if not provided).
If no matching
groupLabelis found:The
labelis set to "Other".The
thumbnailis set to an empty string.
The
groupIdandidare always set to the original group value from the offer.If the
offersarray is empty, an empty array is returned.If the
groupLabelsarray is empty, all groups will have the label "Other" and an empty thumbnail.
Last updated
Was this helpful?

