1
Create one server entrypoint
createMeridianApp reads MERIDIAN_APP_ID, MERIDIAN_API_KEY and MERIDIAN_API_URL from the environment. Create it once and import it everywhere.app/meridian.server.ts
configured is false and every method returns its unconfigured result, so your app still builds and renders. See createMeridianApp.2
Wire the install in afterAuth
One call registers your Shopify webhooks, reports the authentication so your install automations fire, reports the shop’s Shopify subscriptions and their trial length (which is how apps billing through the Shopify Billing API get trials into Meridian), and attributes an affiliate referral if there is one.Meridian resolves the webhook topic set from your dashboard configuration, so you never declare topics. Passing
app/shopify.server.ts
request matters only if you run an affiliate program. Version 3 of @shopify/shopify-app-react-router, which the current Shopify template uses, passes no request to afterAuth: call meridian.afterAuth(session), and affiliate attribution falls back to the referral Meridian stored when the merchant clicked the link.3
Mint a shop token in your loader
The shop token is the per-shop credential the browser uses. Mint it server-side and pass it down.
app/routes/app.tsx
meridianBaseUrl is the API that minted the token (MERIDIAN_API_URL). It is undefined on production; elsewhere the provider needs it to call the same API.mintShopToken returns null when Meridian is unconfigured or unreachable. Treat that as “render without Meridian”, not as an error.Calling it in a loader is cheap: the app instance caches the handshake, so it costs one identify per shop per token lifetime, not one per request. On serverless hosting, where that cache is cold on every start, persist the token instead. See Persisting the token yourself.4
Mount the provider
app/routes/app.tsx
getShopToken (SDK 3.7.0 and later) asks your app’s server for a new one, and the provider replays the refused call with it. Your component sees a slightly slower call, not an error. See MeridianProvider.The route behind it is your own, app/routes/app.meridian.shop-token.tsx, with an action only. It runs authenticate.admin(request) before it reads the body or mints anything: App Bridge adds its session token to a fetch sent to your app’s origin, and that check is what keeps the shop’s token from anyone without access to the store. Then it returns { shopToken } from mintShopToken({ shop: session.shop, refusedShopToken }), never cached, or 503 when the mint returns null. See A token the browser was refused for the code.Once the route is live, createMeridianApp({ browserTokenRefresh: false }) stops a token copied from a page from being refreshed, so it is useless once its hour ends. Without getShopToken, the provider refreshes an expired token itself, so leave that option on. See Turning off refresh without the API key.Gate your first feature
Anywhere below the provider:advanced_reports is the feature’s key, exactly as you typed it in the plan builder. See Feature gating.
Add the pricing page
MeridianPricingPage needs a returnUrl, and it must be an https URL on the shop’s own admin. Build it in the loader, where you have the session shop and your Shopify client ID:
app/routes/app.pricing.tsx
app/routes/app.pricing.tsx
Track a metered action
Where to go next
- Authentication: which credential each call uses, and why
useMeridian: everything the hook exposes- Errors and degradation: what the SDK retries, what it swallows, and what you should handle
- Local development: running your app against a managed developer database