Themes and the storefront SDK
What the platform gives every Liquid theme, and the SDK for themes and headless stores.
A theme owns the look of a store. The platform owns the behaviour that has to be the same everywhere: validation of Brazilian data, forms, the customer account and its session. Themes use those pieces instead of rewriting them, so a fix reaches every store at once.
What every page gets
Every page, in the layout, templates and sections alike, receives shop,
request, routes, cart, customer (when someone is signed in), template,
settings, locale, discounts, cms, forms, brand, menus,
canonical_url, and portal on the account pages. Each page type adds its own
subject: product on a product page, collection on a category, search on
the search page, order on the confirmation page, and so on.
The Theme reference lists the page types with their
addresses, and every object with every field: its type, whether it may be
absent or nil, and what it means. It is generated from the platform code, so
it is exact. To look at an object while you build, print it with the json
filter, as in {{ product | json }} (debugging).
Structured data
The platform adds schema.org JSON-LD to the <head> of every theme's pages:
Organization (the store's name, home page and logo: the header's image, else
the brand's) and WebSite with a SearchAction on the store search on the
home page, and a BreadcrumbList on product pages (Início / Produtos /
product) and category pages (Início / Categorias / category). A page that
already prints a block of one of these types keeps its own: a Store or a
LocalBusiness counts as the Organization. The product's Product (or
ProductGroup, one Product per variant) comes from the platform's product
section. Stores have one language, so pages carry no hreflang.
Sections
Pages are made of sections, like Shopify's Online Store 2.0. A JSON template lists them and their order, and the layout places section groups:
{
"sections": {
"hero": { "type": "slideshow", "settings": { "source": "cms", "cms_collection": "hero-videos" } },
"news": { "type": "featured-collection", "settings": { "heading": "Novidades", "card_badge": "Novo" } }
},
"order": ["hero", "news"]
}{% sections 'header-group' %}
<main>{{ content_for_layout }}</main>
{% sections 'footer-group' %}sections/header-group.json and sections/footer-group.json have the same
shape as a template. The platform ships the sections, so a theme only
chooses, orders and styles them:
| Section | What it is |
|---|---|
header | Logo (image or text), menu links, secondary links in the mobile menu, search, account and cart. |
footer | Logo, a sign-up form, columns of links, contact lines with icons, payment logos. |
announcement-bar, image-banner, rich-text, image-with-text, video, collapsible-content, form | Content blocks. |
slideshow | Images and videos, per device, from blocks or from a CMS collection (asset, poster, viewport, link). |
featured-collection | Products: the newest, all, or one collection, through the platform's product card. |
collection-list | Category cards, name below or over the image. |
multicolumn | Columns with an icon or image, title and text ([pix] becomes the store's PIX discount). |
whatsapp-button | The floating WhatsApp button. |
popup | Places the store's popups (Grow > Popups) and sets their look; the popup script loads after the page. |
Product grids use {% render 'mobiari-product-card', product: product %}
(optional badge: and button:). It shows the price the customer pays
(the promotional compare_at_price when set), the struck price, installments
(card_installments in the theme settings), the PIX price and the "Esgotado"
badge. Every amount is <span class="mb-price" data-cents="...">.
Restyle everything through the --mb-* custom properties and the mb-*
classes; the platform's base CSS loads first, so the theme's rules win. A
theme file with the same name, sections/<type>.liquid with its own
{% schema %}, replaces a platform section, and a section of the theme's own
works the same way. Publishing refuses a page that names a section or block
type that does not exist.
Forms
Forms are built in the admin (Loja online > Formulários): typed fields (text, e-mail, phone, CPF, CNPJ, CPF or CNPJ, CEP, number, date, choices, consent), notification e-mails and customer tags. Put one on a page with the built-in snippet:
{% render 'mobiari-form', form: forms.contato %}It renders a plain HTML form that works without JavaScript. The SDK upgrades
it: masks as the visitor types, the server's rules before sending, field
errors from the server, Cloudflare Turnstile when the platform has it, and
mobiari:submitted / mobiari:error events. The server validates and stores
every value in canonical form (digits, E.164 phone), completes the customer
by e-mail and notifies the store.
Style it with the mobiari-form, mobiari-field, mobiari-field__label,
mobiari-field__input, mobiari-field__error and mobiari-form__submit
classes, or ship your own snippets/mobiari-form.liquid keeping the same
names, name attributes and data-* attributes.
Tags and filters from Shopify themes
Besides Liquid's standard tags and filters, the platform takes the pieces a Shopify-style theme reaches for, mapped to its own:
{% form 'type', object, class: '...' %}...{% endform %}writes a<form>with Shopify's hiddenform_typeandutf8inputs and every named argument as an attribute.productadds to the cart (a plain post withidandquantityworks without JavaScript and opens the cart);cartopens the cart page, where checkout runs;contactandcustomer(a newsletter) post to a store form: the one you pass (forms.contatoor its slug), else the form with slugcontatoornewsletter, andcontact[email]field names reach itsemailfield;customer_login,create_customer,recover_customer_passwordandguest_loginopen the sign-in page (they post, and what was typed is dropped, so a password field never reaches an address: customers sign in with an e-mail code there). Inside,form.errorsis nil. Any other type fails when the theme is checked. Liquid here has no?in names, so writeform.posted_successfullychecks as a script that reads the#form-enviadoanchor the store form returns to.{% paginate list by 12 %}...{% endpaginate %}: inside, the list holds the current page andpaginatedescribes the pages. On a category, a taxonomy term or all products the server pages the list (filters and order kept in the addresses), and a number afterbyis the page size; on the search page it is the server's page ofsearch.results; any other list (CMS entries, a section's products) is paged with?pagina=N.{{ paginate | default_pagination }}writes the page links (prev,page,current,decoandnextspans);previous:andnext:change the arrows' words.{{ image | image_url: width: 600 }}gives the URL of the library rendition that covers the size (height:too,format: 'jpg'for JPEG). It takes a URL, an image object or a product. Renditions are 200, 400, 800 and 1600 px and keep the picture's proportions, socrop:is accepted but does not cut: crop with CSS (object-fit: cover). An image that is not in the store's library comes back unchanged.{{ url | image_tag: alt: '...', class: '...' }}writes an<img>withloading="lazy", the library'ssrcsetand the named arguments as attributes.
Your own inputs
Add data-mobiari to any input to get the platform's mask and validity
message:
<input name="cpf" data-mobiari="cpf" required>
<input name="telefone" type="tel" data-mobiari="phone">Types: phone, cpf, cnpj, document (CPF or CNPJ), cep, email. A
native required form then refuses a CPF with a wrong check digit like it
refuses an empty field. The canonical value is in data-mobiari-value.
The store's own product fields
A store can define fields for its products and variants (wood type, warranty,
width in cm) and choose which ones the storefront shows. Those arrive as
product.fields, a list in the admin's order that only has fields with a
value. Every item brings its own label, so a loop needs no knowledge of the
store:
{% for field in product.fields %}
<dt>{{ field.label }}</dt><dd>{{ field.display }}</dd>
{% endfor %}field.value is the raw value (text, number, true/false, or a list for a
multiple choice) and field.display the text for the page (120,5 cm, Sim,
24/10/2026, Carvalho, Pinus). field.group lets you build one table per
group. To read one field by key, use product.field.<key>, for example
{{ product.field.largura.display }}. Variants have the same variant.fields
and variant.field.<key>. The default main-product section's specifications
block already lists them after the specification groups. The full list of keys
is in the theme reference.
Addresses of the built-in pages
A store can move the built-in pages: /produtos/{handle} can be /loja/{handle},
/carrinho can be /sacola, or the whole set can be English. Themes never
hard-code those paths:
- Link with the
routesobject:routes.cart_url,routes.account_url,routes.search_url,routes.wishlist_url,routes.products_url,routes.collections_url, and for one product or categoryroutes.product_url_pattern/routes.collection_url_pattern(/loja/{handle}):{{ routes.product_url_pattern | replace: '{handle}', product.handle }}. - Links saved in menus and sections (
/produtos,/products/x) are printed at the address in force. - Every earlier address (the platform's own, an English spelling, a previous
choice) redirects permanently to the new one, so indexed pages and old links
keep working. A theme from before addresses could move that prints
{{ routes.products_url }}/{{ product.handle }}still lands on the product.
The addresses are a store setting, changed in the Mobiari admin under
Storefront → Storefront addresses. Reading and changing them is not part
of the public API yet. An address is lowercase
words, - and _, ends with the page's placeholder when the page is one of
many ({handle}, {number}, {id}), cannot start with a word the platform
uses (/v1, /images, /files...), cannot answer the same address as another
page, and cannot hide a page made in the editor. A store that changes nothing is
served exactly as before.
The customer portal
/conta, /conta/pedidos, /conta/pedidos/{number}, /conta/produtos
and /conta/entrar are rendered by the platform inside your
layout/theme.liquid, so the header, footer and CSS stay yours. Customers
sign in with a one-time code by e-mail (or WhatsApp) or a password, and see
each item's stage (received, in production, shipped, delivered), shipments
with tracking, the DANFE and any cartas de correção.
The session is an HttpOnly cookie on the store's own domain. Theme scripts
cannot read it, and nothing should keep customer tokens in localStorage.
Style the portal through the mobiari-portal classes (mp-card, mp-chip,
mp-nav...).
Calling the API from a theme
Besides the Liquid forms (the mobiari-form snippet, the account portal,
the platform's cart and search sections), a theme can talk to the
Storefront API straight from its scripts, like a
headless app. Two values are rendered into every page for that:
| Liquid | What it is |
|---|---|
routes.api_url | The API base on the store's own domain, /v1/storefront. Build calls from it: {{ routes.api_url }}/products?search=cama. |
shop.storefront_key | The store's publishable key (pk_live_...), or nil if the lookup failed. |
On the store's own domain the request's Host already names the store, so a
theme script needs no key; shop.storefront_key is for the rare script
that calls the API from another origin. The key is public, but still treat it
as configuration, not as a place to keep anything else.
The cart is the one thing a script has no id for. Use the alias
current: the cart named by the cart_id cookie, started on the first
write.
<script>
const api = {{ routes.api_url | json }};
async function add(variantId) {
const res = await fetch(`${api}/carts/current/items`, {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ variant_id: variantId, quantity: 1 }),
});
const cart = await res.json(); // the whole cart, priced
if (!res.ok) return alert(cart.error); // cart.code is `insufficient_stock`, ...
}
</script>When to use which:
- Liquid and the platform's pieces for what the server can render: pages, the cart page, forms, the portal. They work without JavaScript.
- The JSON API for what changes without a page load: the cart drawer, search suggestions, shipping estimates, wishlist.
- The old
/storefront-api/{store_slug}/api/...URLs are gone. Theme form endpoints (/storefront-api/{slug}/cart/addand friends) stay internal and answer the platform's own sections; do not build on them.
The SDK
Stores serve the browser build at /_/sdk/storefront.js. The platform adds
it to any page that uses a <mobiari-...> element or a data-mobiari
input, and it exposes window.Mobiari. A page whose only use is
<mobiari-form> gets it when the first form is about to scroll into view (or
takes the focus), so window.Mobiari does not exist before that; pages with
data-mobiari inputs, <mobiari-login>, code in the page that calls
Mobiari.createClient or Mobiari.br, and any page that loads a script file
of its own (the platform cannot see what that file calls) load it at once.
The tracker script (/_/m.js) adds to the same object, whichever of the two
loads first: Mobiari.track(name, props), Mobiari.identify(traits) and
Mobiari.setCart(id). Guard the call, since the tracker can be blocked:
if (window.Mobiari && Mobiari.track) Mobiari.track('view_product', {...}).
The default theme's cart drawer adds Mobiari.cart to it as well: open(),
close(), refresh(), add(variantId, qty, opts) and change(variantId, qty).
| Element | What it does |
|---|---|
<mobiari-form> | A store form (above). Also <mobiari-form store="loja" form="contato"> to render one by itself. |
<mobiari-login> | Customer sign-in: code, password, forgot password. |
Headless stores
Headless stores install @mobiari/storefront. One client covers the whole
storefront API, typed from its OpenAPI document; Mobiari runs stock, freight,
payment and orders, the store brings the pages. The client is built from the
store's publishable key:
import { createClient, br } from '@mobiari/storefront'
const client = createClient({
key: 'pk_live_...',
apiBase: 'https://api.mobiari.com/v1',
})| Group | What it does |
|---|---|
catalog | Products (filters, sort, cursor), categories, collections, shipping estimates, reviews, back-in-stock and price alerts. |
wishlist | Save products, with e-mail alerts for signed-in customers. |
cart | Lines, discount code, contact, shipping or pickup, gift cards (selling them), credit (paying with codes and store credit). |
checkout | Payment methods, installments, pay, wait for the payment. |
customer | Sign-in, account, addresses, orders (with danfe and correction PDFs), returns, credit, privacy. |
forms and locations | Store forms and the pickup points. |
The method names, options and types are in the SDK's README
(sdk/storefront/README.md); this page does not repeat them. To call the API
without the SDK, or to see the sequence of calls from catalog to paid order,
read the Storefront API guide.
Things worth knowing whichever way you call it:
- Cards. Tokenize the card in the browser with the gateway's own SDK (the
public key is in the
payment-methodsanswer) and send the token. On a store whose card gateway is Asaas the payment'snext_action.typeisredirect: send the shopper to that page, then poll the payment. Card data never touches your server. next_actionis told apart by itstype:pix_qr(qr_code_base64,copy_paste,expires_at),redirect(url) orcard_result.- Errors carry a
code(insufficient_stock,payment_required...); the guide lists them all. A failed payment is not an error: read the payment'sstatus. - Validators.
br.phone('(11) 98765-4321')and the otherbrvalidators run the same cases as the server (common::br), so the browser and the server never disagree about a CPF or a phone. - Returns. A signed-in customer can send items back. The
returnablecall says per order line how many units are left to return and whether they can ask now (open, otherwiseclosed_reason); the store approves or rejects the request (see returns).
Rules worth keeping
- The server is the authority: validate in the browser for the visitor's sake, never instead of the server.
- Never put customer tokens or personal data in
localStorageor URLs. - Write forms and sign-in through the platform's pieces; a theme that posts its own copy loses the validation, spam protection and customer records.
Push notifications
What the Mobiari mobile apps receive by push. The kinds of notification, what each push carries, where a tap leads, and how operators turn APNs and FCM on.
Theme reference
Every object and field a Liquid theme receives on each page of the hosted storefront, generated from the platform code.