Hydrogen server setup
Install the package:
npm install @aabhastech/shopify-vtoEnvironment variables
Section titled “Environment variables”| Variable | Exposure | Purpose |
|---|---|---|
AABHAS_BACKEND_BASE_URL |
Server only | Aabhas backend used for eligibility and session exchange. |
AABHAS_INSTALLATION_CREDENTIAL |
Server only | Installation authentication. Never expose this to browser code. |
PUBLIC_AABHAS_BACKEND_BASE_URL |
Public | Browser storefront API base URL. |
PUBLIC_STORE_DOMAIN |
Public | Permanent Shopify *.myshopify.com domain. |
PUBLIC_STOREFRONT_API_TOKEN |
Public | Shopify Customer Privacy integration. |
PUBLIC_CHECKOUT_DOMAIN |
Public | Shopify checkout domain. |
Eligibility and session exchange
Section titled “Eligibility and session exchange”Use the server entry point in a loader or server utility:
import { checkEligibility, exchangeSession,} from '@aabhastech/shopify-vto/core/server';
const config = { backendBaseUrl: context.env.AABHAS_BACKEND_BASE_URL, installationCredential: context.env.AABHAS_INSTALLATION_CREDENTIAL,};
const eligibility = await checkEligibility(config, { shopDomain: context.env.PUBLIC_STORE_DOMAIN, productId: product.id, variantId: variant.id,});
const session = eligibility.eligible ? await exchangeSession(config, { requestOrigin: new URL(request.url).origin, anonymousSessionId, }) : null;Use Shopify GIDs returned by the Storefront API. Do not send organization IDs, template IDs, license keys, garment URLs, or workflow variables from browser code.
Token lifecycle
Section titled “Token lifecycle”Storefront tokens are short-lived and exact-origin scoped. Keep them in JavaScript memory. The server credential is used to refresh a storefront session; it must not be stored in cookies, local storage, HTML, or analytics.