v0.1.0-alpha.1 · alpha not on npm yet MIT

One checkout.
Every market.
Zero vendor lock.

Reactive payment orchestration for modern web apps. The right provider, the right methods, the right flow, picked in the browser the moment your app knows enough to decide. Headless, typed, MIT.

Today: Stripe and Polar, with React bindings. More providers and payment methods are planned.

$ git clone https://github.com/farisaziz12/tenderlane
routing.ts re-evaluating
// context
{ country: ' ' , currency: 'chf' , amount: 2900 }
// rules · first match wins
// fallback
{ provider: 'stripe', flow: 'hosted' }
Total · CHF
CHF 29.00
ROUTE · ch-inline
Flow
inline
Provider
stripe
Try it · change country

The rules run through the real router, in your browser. The checkout is a preview: no provider is called.

Works today with
StripePolarReactNext.js
what is not built yet
What's different

A checkout that knows what your app knows.

Every payment SDK lets you take a payment. Tenderlane decides which payment to take, in the browser, the moment the context changes, with types that hold across providers, markets and methods.

01

Adapts the second your app does.

When the customer changes country, currency or cart, the checkout re-routes in the same render: provider, payment methods and flow. No reload, and no request to your server to decide.

Works today

02

Your UI. Your stack. Any provider.

Headless components, a core that knows no framework, and adapters you can swap. Start on Stripe. Add Polar as your merchant of record. Write an adapter for your local provider with the same API ours use.

Stripe, Polar and React today · more providers and frameworks planned

03

Routing rules are data, not code.

A JSON shape where the first match wins. Store rules in a database, ship them from a feature flag, and catch the typo in "gpb" at compile time.

Works today · no rule editor yet

Before → after

What checkout routing usually looks like.

The same requirement both times: "show TWINT in Switzerland, fall back to Stripe Checkout everywhere else." Left: how it tends to get written. Right: how it reads with Tenderlane.

Hand-rolled checkout.tsx · illustrative
hand-rolled/checkout.tsx
const [provider, setProvider] = useState('stripe');
const [methods, setMethods] = useState(['card']);
const [flow, setFlow] = useState('checkout-session');

// re-run when country changes
useEffect(() => {
  if (country === 'CH') {
    setFlow('payment-intent');
    setMethods(['card', 'twint']);
  } else if (country === 'NL') { /* … */ }
}, [country]);

// re-run when currency changes
useEffect(() => { /* … */ }, [currency]);

// ...and the same conditions again in the submit handler and the API route.
  • Provider and method names are plain strings, so a typo ships
  • The outcome depends on which effect ran last
  • The same conditions are repeated on the server, or not checked there at all
  • Changing a rule means changing code in three places
tenderlane routing.ts · real, typechecked
docs-site/snippets/twint.ts
import { createRulesRouter } from '@tenderlane/core';

export const routing = createRulesRouter({
  rules: [
    {
      id: 'ch-inline',
      when: { country: 'CH', currency: 'chf' },
      use: { provider: 'stripe', flow: 'inline', paymentMethods: ['card', 'twint'] },
    },
  ],
  fallback: { provider: 'stripe', flow: 'hosted', paymentMethods: ['card'] },
});

// The checkout page and the server both read this.
// Rules are plain data: keep them in code, a database or a feature flag.
  • Provider, flow, country and currency are checked by the compiler
  • The first rule that matches wins, and that is the whole contract
  • The route follows the context synchronously: no effects to race
  • Rules are JSON: test them, store them, ship them from a flag
What you write

The whole integration, on screen.

One file, one provider, one router. Experiments, more providers and your own adapters build on this same shape. This is a real file from the repository, typechecked in CI.

01
Clone and run
The packages are not on npm yet. The example runs from the repository.
02
Describe your context
What your app knows: country, currency, amount, experiment.
03
Write rules
In code, in a database or behind a feature flag. Same shape.
04
Mount the provider
A React tree subscribes. The UI updates when the context does.
05
Render your own checkout
You own the button. Tenderlane tracks where the checkout is.
docs-site/snippets/checkout.tsx
import { TenderlaneCheckoutForm, TenderlaneProvider } from '@tenderlane/react';
import { stripeProvider } from '@tenderlane/stripe';
import { StripePaymentElement } from '@tenderlane/stripe/react';
import { routing } from './routing';

const stripe = stripeProvider({
  publishableKey: 'pk_test_...',
  serverEndpoint: '/api/payments',
});

export function Checkout({ country }: { country: string }) {
  return (
    <TenderlaneProvider config={{ context: { country }, providers: [stripe], routing }}>
      <TenderlaneCheckoutForm
        input={{
          items: [{ sku: 'pro-plan', quantity: 1 }],
          successUrl: 'https://shop.example/success',
          cancelUrl: 'https://shop.example/cancel',
        }}
        elements={{ stripe: StripePaymentElement }}
      >
        {({ submit, canSubmit, error }) => (
          <>
            <button disabled={!canSubmit} onClick={submit}>
              Pay
            </button>
            {error && <p role="alert">{error.message}</p>}
          </>
        )}
      </TenderlaneCheckoutForm>
    </TenderlaneProvider>
  );
}
Works today

The compiler knows which providers you registered.

A rule that names any other provider does not compile. Neither does a mistyped currency or flow. These are real errors: the file only compiles because each one is marked as expected.

docs-site/snippets/type-errors.ts
createRulesRouter({
  rules: [
    {
      id: 'uk',
      // @ts-expect-error Type '"gpb"' is not assignable to type 'CurrencyCondition'.
      when: { currency: 'gpb' },
      use: { provider: 'stripe', flow: 'hosted' },
    },
  ],
  // @ts-expect-error Type '"embedded"' is not assignable to type 'PaymentFlow'.
  fallback: { provider: 'stripe', flow: 'embedded' },
});

createTenderlaneClient({
  context: {},
  providers: [stripe],
  // @ts-expect-error Type '"stripe" | "polar"' is not assignable to type '"stripe"'.
  routing: createRulesRouter({
    rules: [{ id: 'us', when: { country: 'US' }, use: { provider: 'polar', flow: 'hosted' } }],
    fallback: { provider: 'stripe', flow: 'hosted' },
  }),
});
Architecture

Four layers. Each one swappable.

A core that knows nothing about your framework, a headless state machine on top, framework bindings, and provider adapters. The layering is inspired by TanStack; this is an independent project.

YOUR APP STATE country currency cart.amount user.tier ab.variant L1 · CORE @tenderlane/core types · errors rulesRouter first-match-wins server handler price · confirm L2 · CLIENT client (state machine) framework-agnostic evaluating ready preparing prepared submitting success / error redirecting / pending L3 · BINDINGS react TenderlaneProvider vue experimental svelte planned vanilla use client directly L4 · ADAPTERS stripe hosted · inline polar hosted adyen planned paypal planned your-psp write the adapter SERVER · isomorphic Web Request/Response handler @tenderlane/core/server accepts { provider, action, payload } · built on Web Request and Response Next.js (tested) Bun Deno Workers
L1 · core
@tenderlane/core

Types, rules router, catalogs, errors, and the server handler that sets the price and confirms payments. Zero runtime dependencies.

L2 · client
@tenderlane/client

A headless state machine with no framework: ready → submitting → success, redirecting or pending.

L3 · bindings
@tenderlane/react · @tenderlane/vue

React provider, hook and form via useSyncExternalStore. Vue is experimental (hosted flow only). Svelte and Solid are planned.

L4 · adapters
@tenderlane/stripe · @tenderlane/polar

One per provider. Stripe and Polar today. Stripe.js is loaded only when an inline route needs it.

* Stripe.js is loaded only when an inline Stripe route needs it. A hosted-only checkout ships no provider JavaScript. Next.js is the only server runtime tested so far.

Philosophy

Three rules the codebase lives by.

Tenderlane is not a backend payment wrapper. It connects what your application knows to the providers that take the money, and it has opinions about how.

01

Frontend-first orchestration

Routing happens in the browser, where the app already knows the user's country, currency, experiment variant, and cart shape. The server handler sets the price, checks the route again and confirms the payment. It does not decide what to render. State changes the UI; the UI does not wait on a request.

02

Typed end-to-end

Provider ids stay string literals all the way from the adapters you register to the rules you write. A rule that names a provider you did not register does not compile, and neither does a mistyped flow or currency. A checkout status narrows the fields you can read.

03

Provider-agnostic by default

`@tenderlane/core` has zero runtime dependencies and never imports a provider SDK. Stripe, Polar and every future adapter live behind the same contract. Swap providers, run two side by side or A/B test them, without rewriting your checkout UI or your server.

Where it stands

Honest scope. Pre-1.0.

The page above describes where Tenderlane is going. This is how much of it exists today.

works today
  • Rules router, shared by the browser and the server
  • Headless checkout client, typed by status
  • React bindings via useSyncExternalStore
  • Stripe: Checkout (hosted) and Payment Element (inline)
  • Polar: hosted checkout
  • Server-side pricing from a catalog (inline, remote, Stripe or Polar)
  • Payment confirmation: order hook, status lookup, verified webhooks
  • An adapter API for your own provider
partly
  • Vue bindings: hosted flow only, no example
  • Webhooks: payment events only; no refunds, disputes or subscriptions
  • Stripe test-mode suite: written, not yet run
  • Polar: mocked tests only, one product per checkout
planned
  • More providers: Adyen, Paddle, PayPal, Mollie
  • Subscriptions and refunds
  • Failover between providers
  • Svelte and Solid bindings
  • Polar embedded checkout
  • A rule editor and devtools
  • npm releases and a stable 1.0
CONTRIBUTING
If you need an adapter or binding that is not here, open an issue. A provider adapter is two small objects.
Open issues

Don't request a demo.
Just read the code.

MIT and on GitHub. No sales call, no "talk to us". It is an alpha: clone it, run the example without an account, then add Stripe test keys and route a real test payment.

$ git clone https://github.com/farisaziz12/tenderlane