T402 API Reference - v2.8.0
    Preparing search index...

    Function paymentProxy

    • Next.js payment proxy for t402 protocol (direct server instance).

      Use this when you want to pass a pre-configured t402ResourceServer instance. This provides more flexibility for testing, custom configuration, and reusing server instances across multiple proxies.

      Parameters

      • routes: RoutesConfig

        Route configurations for protected endpoints

      • server: t402ResourceServer

        Pre-configured t402ResourceServer instance

      • OptionalpaywallConfig: PaywallConfig

        Optional configuration for the built-in paywall UI

      • Optionalpaywall: PaywallProvider

        Optional custom paywall provider (overrides default)

      • syncFacilitatorOnStart: boolean = true

        Whether to sync with the facilitator on startup (defaults to true)

      Returns (req: NextRequest) => Promise<NextResponse<unknown>>

      Next.js proxy handler

      import { paymentProxy } from "@t402/next";
      import { t402ResourceServer } from "@t402/core/server";
      import { registerExactEvmScheme } from "@t402/evm/exact/server";

      const server = new t402ResourceServer(myFacilitatorClient);
      registerExactEvmScheme(server, {});

      export const proxy = paymentProxy(routes, server, paywallConfig);