Getting Started with ONLang: How to Ship Your First Self-Optimizing Paywall in 1 Hour
A code-first ONLang quickstart for registering native paywall components, publishing a safe hypothesis, and starting an experiment with a holdout.
Key Takeaways
- The one-hour quickstart is a guided target, not a guarantee: an existing native paywall and working billing integration make it realistic to focus on ONLang setup rather than rebuild checkout.
- The workflow is register components, install the platform SDK, define and lint a finite hypothesis, publish it, then start an experiment with an explicit holdout.
- ONLang keeps StoreKit 2, Play Billing, RevenueCat, or existing purchase functions intact and provides bundled fallbacks and kill controls for safe rollout.
This guide takes an existing subscription paywall and adds one controlled remote hypothesis. It deliberately avoids a billing migration and a visual redesign. By the end, you should have a registered native component, a bundled fallback, a validated token experiment, and a tested way to disable delivery.
The “1 hour” in the title is a focused setup target for a prepared app, not a measured universal benchmark. Package resolution, signing, store sandbox setup, native build issues, and app-specific accessibility tests can take longer. Treat the sequence as a vertical slice, not a promise to skip engineering review.
Prerequisites and account setup
You need an existing iOS, Android, or React Native app with a working native paywall, known product identifiers, and purchase code you can leave unchanged. Prepare a development environment, a test placement named paywall, and sandbox accounts for purchase and restore testing.
Registration is open. Every new app receives a 14-day full-featured trial, including production use and real users; no card is required to sign up. After the trial, each app needs a plan, paid through PayPal: $19/month for orders up to $3,877/month, $39/month up to $7,959/month, or $49/month at any volume (the flat plan can also be paid as 2,500 Telegram Stars per 30 days). Create your ONLang app and keep server credentials out of client code. ONLANG_TOKEN belongs in a protected terminal or CI environment, never in a VITE_ variable or application bundle.
Install the CLI (@on-lang/cli, binary onlang) in the project or invoke it with your package runner:
npx @on-lang/cli init
onlang --help
onlang init scaffolds onlang.config.ts, a starter onlang/registry.json, a paywall template and a base composition. Inspect the generated configuration before committing it, and do not commit access tokens. If your team uses pnpm, Yarn, or Bun, equivalent dlx or bunx invocation is available as shown in the platform guides.
Install the native SDK
For iOS, add OnlangKit through Swift Package Manager. Add optional OnlangStoreKit or OnlangRevenueCat integration only when it matches the purchase layer you actually use. The app registers components through OnlangRegistry and presents a flow with OnlangFlowView or OnlangFlowViewController.
For Android, add io.onlang:onlang-kit:1.0.0, the billing artifacts required by your existing integration, and optional onlang-compose. Use OnlangFlowView or OnlangFlow according to the app’s View or Compose architecture.
For React Native, install @on-lang/react-native and @react-native-async-storage/async-storage, with @on-lang/cli as a development dependency:
npm install @on-lang/react-native @react-native-async-storage/async-storage
npm install --save-dev @on-lang/cli
npx pod-install
npx pod-install is only relevant to bare React Native apps, for AsyncStorage's own pod. Follow the complete iOS guide, Android guide, or React Native guide for package configuration and imports. The React Native SDK is pure JavaScript with no native module of its own.
Define the component registry
Start with semantic components that already exist in the app. Do not model every padding value as remote input. A useful first registry contains an intro, a two-product plan toggle, and a purchase button with bounded text.
Replace the starter onlang/registry.json:
{
"registry": "acme_fitness",
"version": "1.0.0",
"products": ["annual", "monthly"],
"components": {
"PaywallIntro": {
"props": {
"headline": { "type": "token", "max_chars": 40 },
"body": { "type": "token", "max_chars": 90 }
}
},
"PlanToggle": {
"props": {
"products": { "type": "products", "min_items": 2, "max_items": 2 },
"default": { "type": "product" }
},
"interactive": true,
"emits": ["select"]
},
"PurchaseButton": {
"props": {
"title": { "type": "token", "max_chars": 28 }
}
}
}
}
Replace acme_fitness with your registry name and annual and monthly with the identifiers your app configuration expects. Do not copy those names blindly into a production catalog. Product actions should resolve through the existing store adapter.
The registry is a security and design boundary. It does not accept executable code. Interactive components emit declared actions such as selection, while native code owns purchase and restore behavior.
Register and render native components
On iOS, wrap your existing SwiftUI or UIKit components and register their typed props with OnlangRegistry. Render the placement through OnlangFlowView, retaining your current paywall as the fallback. On Android, perform the equivalent registration with Views or Compose. React Native uses registered React components with OnlangFlow.
A React Native fallback boundary looks like this:
import React from "react";
import { ActivityIndicator, View } from "react-native";
import { OnlangFlow } from "@on-lang/react-native";
import { ExistingPaywall } from "./ExistingPaywall";
export function PaywallScreen({ onClose }: { onClose: () => void }) {
return (
<OnlangFlow
placement="paywall"
onFinished={(result) => {
if (result.outcome !== "failed" && result.outcome !== "killed") onClose();
}}
renderLoading={() => (
<View accessibilityLabel="Loading subscription options">
<ActivityIndicator />
</View>
)}
renderFallback={() => <ExistingPaywall />}
/>
);
}
Use the package and guide’s registry/context props for your complete integration; this excerpt focuses on the fallback contract. The existing paywall must remain purchasable and include restore, terms, privacy, and required disclosures.
Do not create a second entitlement state inside these components. Selection is UI state; transaction and subscription ownership still come from StoreKit, Play Billing, RevenueCat, or your backend.
Bundle a known-good composition
Before publishing a variation, compose the control locally and include it in the app:
onlang compose --placement paywall --locale en --out build/onlang/paywall
--out writes composition.json, manifest.json and the compiled screen bundles; ship them with the app so first launch can work offline. The runtime flow is network → cache → bundled composition, with the application’s own paywall as the final fallback after failed or killed delivery. A malformed network response must not overwrite the last validated cache.
Test this before enabling an experiment. Enable airplane mode, cold-start the app, open the paywall, and verify plan selection, product prices, restore, terms, and purchase error handling. A bundled contract does not guarantee the store can complete a transaction offline; it guarantees a coherent native interface and recovery path.
Offline-first dynamic paywalls explains freshness, assignment persistence, and time-to-interactive instrumentation. The migration blueprint expands the parity checklist.
Create a finite hypothesis
Use one low-risk CTA hypothesis with two human-approved variants. The rationale states what is being tested, and the variants change only the allowed token.
onlang hypothesis create --id paywall.cta.copy --kind tokens --screen paywall \
--key cta.title --rationale "Name the outcome, not the step" \
--variant "outcome=Get my plan" --variant "trial=Try Pro free for {{trial.annual}}"
onlang lint
Ensure cta.title matches the key defined by your hypothesis configuration and that {{trial.annual}} resolves to the real annual trial offer. If the annual product has no trial for an eligible user, do not use that variant. Validation can check token shape; your product facts determine semantic truth.
Review every variant at supported screen sizes and accessibility text settings. Keep auto-renewal terms, legal links, and product identifiers outside the generated variation. Finite hypothesis spaces explains how LLM proposals fit later without bypassing these gates.
Publish and start the experiment
Set the app's secret token (onl_sk_…) only in the publishing environment, then publish and create the experiment. The app itself only ever carries the publishable onl_pk_… key:
ONLANG_TOKEN=onl_sk_… onlang publish
ONLANG_TOKEN=onl_sk_… onlang experiment create --placement paywall --holdout 0.1 --start
ONLANG_TOKEN=onl_sk_… onlang experiment status <id>
onlang publish sends the release to the target set in onlang.config.ts; without --target it uses staging, which the starter config points at a local onlang dev-server. Replace <id> with the created experiment identifier. The 10% holdout is an example, not a universal recommendation. Choose it from traffic, baseline conversion, minimum detectable effect, and readout requirements. Holdout-group methodology explains the trade-off.
In the console, verify that the placement, release, hypothesis, and experiment match the intended app environment. Confirm exposure events only when a user actually sees the screen. Purchases must come from store or entitlement events, not button taps.
ONLang’s optimizer fits a factored Bayesian model over the approved compositions, allocates traffic by Thompson Sampling, and keeps holdout outcomes separate. Bandit optimization covers Thompson Sampling, delayed feedback, and why adaptive allocation does not replace inference.
Rehearse kill and recovery
Before broad rollout, stop the placement:
onlang kill paywall --reason "INC-12: quickstart rollback rehearsal"
onlang kill --status
Open the app and verify that the SDK reports the killed outcome and the app presents its own paywall. Complete a sandbox purchase and restore through that fallback. Then lift the kill deliberately:
onlang kill paywall --lift
Document how quickly devices observe kill state and what happens when they are offline. Test malformed payloads and expired caches too. Operational safety is part of the quickstart, not an optional enterprise feature. Repeat the rehearsal after any registry or fallback change, and record the app version, release identifier, device, and result so the test remains auditable.
If the trial ends without a plan or a later plan lapses, ONLang switches itself off for that app and users see the app’s own paywall, where they can still buy. That is another reason the fallback must be production-quality rather than a static screenshot.
Graduate from setup to optimization
Once one token experiment works, resist adding many dimensions immediately. Validate assignment stability across restarts, cache refreshes, and identity changes. Wait for trial and purchase outcomes to mature before declaring a winner. Monitor refunds, early cancellations, and purchase errors alongside immediate conversion.
New native capabilities still require app releases. Remote contracts optimize approved compositions; they are not a route to arbitrary code generation. When you need new components, version the registry and keep old clients compatible. The Swift and Kotlin architecture guide explains safe deserialization and action routing.
For a longer trial plan including console verification and production transition, continue with the ONLang 14-day trial guide.
Your first-hour checklist
Account and app created; SDK installed; existing components registered; product identifiers verified; bundled fallback tested offline; one hypothesis linted; release published; experiment and holdout confirmed; exposure and purchase events reconciled; kill and fallback rehearsed. If any item remains, finish it before increasing traffic.
Start your ONLang 14-day trial and use the platform guide for your stack alongside this article. The goal is not merely a remote screen—it is a native, measurable, reversible first experiment.