Skip to content

React SDK Installation

Install and set up the GoPayLocal React SDK in your React or Next.js app.

The React SDK provides components and hooks for building PPP-aware pricing in React and Next.js applications.

Terminal window
npm install @gopaylocal/react
  1. Wrap your app with GoPayLocalProvider

    The provider fetches PPP data once and makes it available to all child components.

    app/providers.tsx
    'use client';
    import { GoPayLocalProvider } from '@gopaylocal/react';
    export function Providers({ children }: { children: React.ReactNode }) {
    return (
    <GoPayLocalProvider apiKey="gpl_pk_live_abc123">
    {children}
    </GoPayLocalProvider>
    );
    }
    app/layout.tsx
    import { Providers } from './providers';
    export default function RootLayout({
    children,
    }: {
    children: React.ReactNode;
    }) {
    return (
    <html lang="en">
    <body>
    <Providers>{children}</Providers>
    </body>
    </html>
    );
    }
  2. Use PPP-aware components or hooks

    import { PPPPrice } from '@gopaylocal/react';
    function PricingCard() {
    return (
    <div>
    <h2>Pro Plan</h2>
    <PPPPrice price={9.99} />
    <span>/month</span>
    </div>
    );
    }

The React SDK exports:

CategoryExports
ProviderGoPayLocalProvider
HooksusePPP, usePrice
ComponentsPPPBanner, PPPPrice, PPPPriceFormatted, PPPPriceInteger, PPPPriceDecimal, PPPCurrencySymbol, PPPCurrencyCode, PPPPricingTable
UtilitiescountryToFlag, formatCurrency, splitPrice
TypesPPPConfig, PPPResponse, PPPContextValue, and all component props

The SDK is written in TypeScript and ships with full type definitions. All components, hooks, and utilities are fully typed.

import type { PPPContextValue, PPPResponse } from '@gopaylocal/react';

The React SDK is lightweight and tree-shakable. If you only use PPPPrice, only the PPPPrice component and the usePrice hook are included in your bundle.