Core Utilities and Helpers
Core utilities and helpers available across the Limio SDK — formatting, sanitisation, error handling, address lookups, and component props.
These utilities are imported from @limio/sdk (or its subpaths) and are available in any custom component. They are ordered below roughly by how commonly they are used across production components.
Offer-specific helpers (useOfferInfo, checkActiveOffers, groupOffers) are documented on the Page, Offers & Add-Ons page. Invoice fetching (LimioFetchers.invoiceFetch) is documented on the Billing & Account page.
sanitiseHTML
An HTML sanitisation function that should be used whenever rendering content from offers or CMS fields via dangerouslySetInnerHTML. It uses DOMPurify under the hood and automatically adds security attributes to links.
Most offer attributes that contain rich text — such as offer_features__limio, display_description__limio, or any __limio_richtext prop — should be passed through sanitiseHTML before rendering.
function sanitiseHTML(dirty?: string): stringimport { sanitiseHTML } from "@limio/sdk"
const OfferFeatures = ({ offer }) => {
const featuresHtml = offer.data.attributes.offer_features__limio
return (
<div dangerouslySetInnerHTML={{ __html: sanitiseHTML(featuresHtml) }} />
)
}Behaviour:
Strips all non-HTML-safe tags and attributes.
Preserves the
targetattribute on links.Automatically adds
rel="noopener noreferrer"to links withtarget="_blank", andrel="noopener"to links with other target values.Throws an error if called in a non-browser environment without DOM support (a Node.js version is available internally for SSR).
Important: Always use
sanitiseHTMLwhen rendering user-controlled or offer-sourced HTML withdangerouslySetInnerHTML. This prevents XSS attacks from malicious content in offer attributes.
ErrorBoundary
A React error boundary component that catches JavaScript errors in its child component tree and renders the element you pass as fallback in their place.
Limio wraps every component in an error boundary when it renders it, so it is not necessary to use at the top level. However, ErrorBoundary is useful for wrapping specific children that may error where the parent component should remain functional, for example a subscription details panel that fetches external data.
Props:
children
React.ReactNode
The component tree to wrap
fallback
React.ReactNode
The element to render instead of children when a child throws
fallback is a rendered element, not a component type, so it is not passed the error. If you need the error itself, catch it in the child.
Behaviour:
Catches errors during rendering, in lifecycle methods, and in constructors of child components.
Does not catch errors in event handlers. Use try/catch for those.
Renders
fallbackin place of the failed subtree.Does not report the error itself. The boundary Limio wraps each component in reports to Sentry, and you can report explicitly with
captureException, which the SDK re-exports:
Formatters
formatCurrency
Formats a numeric amount with a currency code and optional locale. This is the most commonly used price formatter — use it in subscription tables, invoice lists, and anywhere you display monetary values.
Parameters:
amount:string | number— The amount to format.currencyCode:string— ISO 4217 currency code (e.g."USD","EUR").locality(optional):string— Locale for formatting.
formatCurrencyForCurrentLocale
A convenience wrapper around formatCurrency that automatically resolves the locale from the limio-country cookie. Use this when you want locale-aware formatting without manually specifying a locale — common in cart summaries and checkout components.
Parameters:
amount:number | string— The amount to format.currency:string— The ISO 4217 currency code.
Returns: A formatted currency string using the browser's Intl.NumberFormat API.
Use
formatCurrencyif you need to specify a locale explicitly.
formatDate
Formats an ISO date string into a human-readable date. Use this when displaying subscription start/end dates, invoice dates, or billing cycle information.
There are two versions, and which one you get depends on where you import from.
From @limio/sdk, to choose the format yourself:
Parameters:
date:string— An ISO 8601 date string.format(optional):DateFormat— One of"DATE_EN","DATE_FULL","DATE_MED","DATE_SHORT","DATE_SHORT_US". If omitted, the date is formatted using the browser locale.
From @limio/sdk/date, to use the shop's configured format:
This version takes a single argument and applies the default date format configured for the shop, so components stay consistent with the environment's settings. It does not accept a format argument.
formatDisplayPrice
Formats a template string by replacing placeholders with values from a price object. Useful for rendering configurable price display strings that include currency symbols and amounts.
Parameters:
template:string— A string containing placeholders (e.g.{{currencyCode}},{{amount}}).offerPrice:Array<LimioPrice>— Array of price objects; the first element is used.
Component Props
useComponentProps and getPropsFromPackageJson are the standard way to load the configurable props defined in your component's package.json. Almost every custom component uses this pattern to read the values that content editors set in the Page Builder.
For full details on defining limioProps in your package.json, see Prop Types and Development Guidelines.
Address Helpers
Utilities for working with addresses — formatting, metadata lookups, and country-specific form configuration. Import from @limio/sdk/address. These are primarily used in account management and checkout components that collect or display delivery and billing addresses.
addressSummary
Takes a Limio address object and returns a formatted single-line string. Returns "N/A" if the address is empty. Use this in subscription detail tables and payment method displays.
formatCountry
Converts an alpha-2 country code into the full country name.
getAddressMetadata
Returns which address fields are required and which should be rendered for a given country. Use this to build dynamic address forms that adjust their inputs based on the selected country — for example, showing a "State" field for US/CA but not for UK addresses.
Returns:
requiredAddressFields:string[]— Fields that must be filled in.addressFieldsToRender:string[]— Fields that should appear in the form.
getCountryMetadata
Returns metadata for a country including its full name and ISO codes.
DateTime
Limio re-exports DateTime from Luxon for date handling. Use it when formatDate isn't flexible enough — for example, when calculating days until renewal or comparing subscription periods.
LimioAppSettings
Provides access to global application settings configured in Limio. Currently exposes the configured date format.
Available methods:
getDateFormat()
string
The date format configured for the current Limio environment
Last updated
Was this helpful?

