CDP Frontend SDK
    Preparing search index...

    Module @coinbase/cdp-react - v0.0.47

    This package contains ready-made, customizable React UI components that wrap the CDP frontend SDK.

    This guide will help you get started with @coinbase/cdp-react. You'll learn how to install the package, set up the provider, and render your first component.

    First, add the package to your project using your preferred package manager.

    # With pnpm
    pnpm add @coinbase/cdp-react @coinbase/cdp-core @coinbase/cdp-hooks

    # With yarn
    yarn add @coinbase/cdp-react @coinbase/cdp-core @coinbase/cdp-hooks

    # With npm
    npm install @coinbase/cdp-react @coinbase/cdp-core @coinbase/cdp-hooks
    1. Sign in or create an account on the CDP Portal
    2. On your dashboard, select a project from the dropdown at the at the top, and copy the Project ID
    1. Navigate to the Embedded Wallet Configuration in CDP Portal, and click Add origin to include your local app
    2. Enter the origin of your locally running app - e.g., http://localhost:3000
    3. Click Add origin again to save your changes

    Next, you need to wrap your application with the CDPReactProvider.

    CDPReactProvider provides the necessary context for hooks and components to work correctly. It also provides access to config data and theming.

    Update your main application file (e.g., main.tsx or App.tsx) to include the provider:

    import React from 'react';
    import ReactDOM from 'react-dom/client';
    import { App } from './App'; // Your main App component
    import { CDPReactProvider, type Config, type Theme } from '@coinbase/cdp-react';

    // Config for your dapp
    const config: Config = {
    projectId: "your-project-id", // Copy your Project ID here.
    appName: "My app", // the name of your application
    appLogoUrl: "https://picsum.photos/64", // logo will be displayed in select components
    }

    // You can customize the theme by overriding theme variables
    const themeOverrides: Partial<Theme> = {
    "colors-bg-default": "black",
    "colors-bg-alternate": "#121212",
    "colors-fg-default": "white",
    "colors-fg-muted": "#999999",
    }

    ReactDOM.createRoot(document.getElementById('root')!).render(
    <React.StrictMode>
    <CDPReactProvider config={config} theme={themeOverrides}>
    <App />
    </CDPReactProvider>
    </React.StrictMode>,
    );

    Now you can use the components from the library. Let's add the AuthButton component to your application. This component handles both sign-in and sign-out functionality.

    // In your App.tsx or any other component
    import { AuthButton } from '@coinbase/cdp-react/components/AuthButton';

    function App() {
    return (
    <div>
    <h1>Welcome</h1>
    <AuthButton />
    </div>
    );
    }

    export default App;

    That's it! You've successfully installed @coinbase/cdp-react, set up the provider, and rendered your first component.

    Functions

    CDPReactProvider
    useAppConfig
    useProviderName
    AuthButton
    SendEvmTransactionButton
    SendSolanaTransactionButton
    SignIn
    useSignInReducer
    SignOutButton
    SignInModal
    ThemeProvider
    useTheme
    flattenTokensObject
    themeToCssVariables
    IconArrowLeft
    IconArrowsUpDown
    IconCheck
    IconCheckCircle
    IconChevronDown
    IconEnvelope
    IconExclamationCircle
    IconExclamationTriangle
    IconLock
    IconPhone
    IconXMark
    clamp
    getMessageFromUnknownError
    isApiError
    isEmailInvalid
    parseValuesFromPhoneNumber
    Fund
    FundFooter
    FundForm
    FundTitle
    useFundContext
    FundModal
    SignInAuthMethodButtons
    SignInBackButton
    SignInDescription
    SignInFooter
    SignInForm
    SignInImage
    SignInTitle
    useSignInContext

    Interfaces

    AppConfig
    CDPReactProviderProps
    AuthButtonProps
    SendEvmTransactionButtonProps
    SendSolanaTransactionButtonProps
    SignInProps
    SignInModalProps
    ThemeContextValue
    PhoneNumber
    FetchBuyUrlParams
    FundFormProps
    FundPaymentMethod
    FundProps
    FundState
    FundTitleProps
    OnrampError
    FundModalProps
    SignInAuthMethodButtonsProps
    SignInBackButtonProps
    SignInDescriptionProps
    SignInFormProps
    SignInImageProps
    SignInTitleProps
    SignInState

    Type Aliases

    AuthMethod
    Config
    SignOutButtonProps
    ThemeProviderProps
    SemanticColors
    ComponentColors
    ColorTokens
    SemanticFonts
    ComponentFonts
    FontTokens
    SemanticBorderRadius
    ComponentBorderRadius
    BorderRadiusTokens
    Theme
    ButtonVariant
    Size
    ButtonSize
    InputSize
    Tokens
    KebabCasePaths
    Flattened
    TokenValue
    NestedTokenObject
    CDPWebCSSVariables
    CamelToSnakeCase
    CamelToSnakeCaseNested
    FundAction
    FetchBuyOptions
    FetchBuyQuote
    FundContextType
    FundLifecycleStatus
    FundPresetAmountInputs
    FundStateError
    FundStateProps
    InputType
    OnrampAmount
    OnrampBuyQuoteResponse
    OnrampBuyOptionsResponse
    OnrampBuyOptionsSnakeCaseResponse
    OnrampBuyQuoteSnakeCaseResponse
    OnrampNetwork
    OnrampPaymentCurrency
    OnrampPaymentMethodLimit
    OnrampPurchaseCurrency
    OnrampSuccessEventData
    SignInAction

    Variables

    OAUTH_METHODS
    AUTH_METHODS
    ALL_AUTH_METHODS
    theme
    colorsBase
    colorsSemantic
    colorsComponents
    colors
    fontSemantic
    fontComponents
    font
    borderRadiusSemantic
    borderRadiusComponents
    borderRadius
    tokens
    cssVariables