SignOutButton
when logged in, and the SignInModal
when logged out@coinbase/cdp-react
. You’ll learn how to install the package, set up the provider, and render your first component.
http://localhost:3000
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:
AuthButton
component to your application. This component handles both sign-in and sign-out functionality.
@coinbase/cdp-react
, set up the provider, and rendered your first component.
Parameter | Type | Description |
---|---|---|
props | CDPReactProviderProps | Props for the CDPReactProvider component |
Element
The CDPReactProvider component
AppConfig
The app config.
Parameter | Type | Description |
---|---|---|
props | AuthButtonProps & HTMLAttributes <HTMLDivElement > | The props for the component. |
Element
The rendered component.
Parameter | Type | Description |
---|---|---|
props | SendTransactionButtonProps | The props for the SendTransactionButton component. |
Element
The rendered component.
Parameter | Type | Description |
---|---|---|
props | SignInProps | The props for the component. |
Element
The SignIn component.
Parameter | Type | Description |
---|---|---|
initialState | SignInState | The initial state of the component. |
SignInState
, ActionDispatch
<[SignInAction
]>]
The current state and dispatcher to perform actions on the state.
Parameter | Type | Description |
---|---|---|
props? | SignOutButtonProps | The props for the component. |
Element
The rendered component.
Parameter | Type | Description |
---|---|---|
props | SignInModalProps | The props for the SignInModal component. |
Element
The SignInModalcomponent.
Parameter | Type | Description |
---|---|---|
props | ThemeProviderProps | The props for the component. |
Element
The theme provider component.
ThemeContextValue
The theme.
Type Parameter |
---|
T extends NestedTokenObject |
Parameter | Type | Default value | Description |
---|---|---|---|
tokensObject | T | undefined | The nested tokens object to flatten. |
cssVarPrefix? | string | "cdp-web" | An optional prefix for the generated CSS variables. |
Flattened
<T
>
A flattened theme object.
Parameter | Type | Description |
---|---|---|
theme | Record <string , string > | The theme object to convert. |
CDPWebCSSVariables
A CSS variables object.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Arrow Left icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Arrow Left icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Check Circle icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Check Circle icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The chevron down icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Envelope icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Exclamation Circle icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Exclamation Triangle icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Lock icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The chat bubble icon.
Parameter | Type | Description |
---|---|---|
props | Omit <SVGProps <SVGSVGElement >, "viewBox" > | The props for the icon. |
Element
The Close icon.
Parameter | Type | Description |
---|---|---|
value | number | The value to clamp. |
min | number | The minimum value. |
max | number | The maximum value. |
number
The clamped value.
Parameter | Type | Default value | Description |
---|---|---|---|
error | unknown | undefined | The error to get a message from. |
defaultMesasge? | string | "Something went wrong" | The default message to return if no message is found. |
string
The message from the error.
Parameter | Type | Description |
---|---|---|
error | unknown | The error to check. |
error is APIError
Parameter | Type | Description |
---|---|---|
value | string | The email address to validate. |
boolean
true
if the email address is invalid, false
otherwise.
Parameter | Type | Description |
---|---|---|
phoneNumber | string | The phone number to parse. |
countryCode? | CountryCode | The country code to parse the phone number for. |
PhoneNumber
A phone number object.
Parameter | Type | Description |
---|---|---|
props | FundProps | The props of the Fund component. |
Element
The Fund component.
Parameter | Type | Description |
---|---|---|
props | HTMLAttributes <HTMLDivElement > | The props of the FundFooter component. |
Element
The FundFooter component.
Parameter | Type | Description |
---|---|---|
props | FundFormProps | The props for the FundForm component. |
Element
The FundForm component.
Parameter | Type | Description |
---|---|---|
props | FundTitleProps | The props for the FundTitle component. |
Element
The FundTitle component.
FundContextType
Parameter | Type | Description |
---|---|---|
props | FundModalProps | The props for the FundModal component. |
Element
The FundModal component.
Parameter | Type | Description |
---|---|---|
props | SignInAuthMethodButtonsProps | The props for the AuthMethodButtons component. |
null
| Element
The AuthMethodButtons component.
Parameter | Type | Description |
---|---|---|
props | SignInBackButtonProps | The props for the component. |
null
| Element
The sign-in back button.
Parameter | Type | Description |
---|---|---|
props | SignInDescriptionProps | The props for the component. |
Element
The rendered component.
Parameter | Type | Description |
---|---|---|
props | HTMLAttributes <HTMLDivElement > | The props for the component. |
Element
The sign-in footer.
Parameter | Type | Description |
---|---|---|
props | SignInFormProps | The component props. |
Element
The rendered component.
Parameter | Type | Description |
---|---|---|
props | SignInImageProps | The props for the component. |
null
| Element
The rendered component.
Parameter | Type | Description |
---|---|---|
props | SignInTitleProps | The props for the component. |
Element
The rendered component.
object
The current state of the SignIn component.
Property | Type | Description |
---|---|---|
app? | AppConfig | The app config |
children | ReactNode | The children of the component |
config | Config | The CDP configuration |
className? | string | - |
style? | CSSProperties | - |
theme? | Partial <Theme > | The theme values to override |
Omit
<ButtonHTMLAttributes
<HTMLButtonElement
>, "onError"
>Property | Type | Description |
---|---|---|
account | `0x${string}` | The account to send the transaction from. |
network | SendEvmTransactionWithEndUserAccountBodyNetwork | The network to send the transaction on. |
onError? | (error ) => void | A function to call when the transaction errors. |
onSuccess? | (hash ) => void | A function to call when the transaction is successful. |
pendingLabel? | ReactNode | The label to show to screen readers when the transaction is pending. |
transaction | AllowedEvmTransactionType | The transaction to send. |
variant? | ButtonVariant | The variant of the button. |
Property | Type |
---|---|
theme | Theme |
cssVariables | CDPWebCSSVariables |
Property | Type |
---|---|
paymentMethod | string |
paymentAmount | number |
Omit
<FormHTMLAttributes
<HTMLFormElement
>, "children"
>Property | Type |
---|---|
id | string |
name | string |
description | string |
icon | ReactNode |
minAmount? | number |
maxAmount? | number |
FundStateProps
.FundLifecycleEvents
Property | Type | Inherited from |
---|---|---|
children? | ReactNode | (state ) => ReactNode | - |
className? | string | - |
fetchBuyOptions | FetchBuyOptions | - |
fetchBuyQuote | FetchBuyQuote | - |
inputType? | InputType | - |
openIn? | "tab" | "popup" | - |
submitLabel? | ReactNode | - |
title? | ReactNode | - |
country | string | FundStateProps.country |
locale? | string | FundStateProps.locale |
cryptoDecimalPlaces? | number | FundStateProps.cryptoDecimalPlaces |
cryptoCurrency | string | FundStateProps.cryptoCurrency |
fiatCurrency | string | FundStateProps.fiatCurrency |
fiatDecimalPlaces? | number | FundStateProps.fiatDecimalPlaces |
network | string | FundStateProps.network |
presetAmountInputs? | FundPresetAmountInputs | FundStateProps.presetAmountInputs |
subdivision? | string | FundStateProps.subdivision |
onError? | (e ) => void | FundLifecycleEvents.onError |
onStatus? | (lifecycleStatus ) => void | FundLifecycleEvents.onStatus |
onSuccess? | (result? ) => void | FundLifecycleEvents.onSuccess |
Property | Type |
---|---|
country | string |
cryptoAmount? | number |
cryptoCurrency | string |
cryptoDecimalPlaces? | number |
exchangeRate? | number |
exchangeRateError? | | null | FundStateError |
isExchangeRatePending? | boolean |
isPaymentMethodsPending? | boolean |
fiatAmount? | number |
fiatCurrency | string |
fiatDecimalPlaces? | number |
locale? | string |
network | string |
paymentMethods? | FundPaymentMethod [] |
paymentMethodsError? | | null | FundStateError |
presetAmountInputs? | FundPresetAmountInputs |
selectedInputType | InputType |
selectedPaymentMethod? | FundPaymentMethod |
subdivision? | string |
transactionStatus | FundLifecycleStatus |
HTMLAttributes
<HTMLDivElement
>Property | Type |
---|---|
as? | ElementType |
Property | Type |
---|---|
errorType | "internal_error" | "handled_error" | "network_error" | "unknown_error" |
code? | string |
debugMessage? | string |
Property | Type | Description | Overrides | Inherited from |
---|---|---|---|---|
children? | ReactNode | The children to render inside the modal. | FundProps .children | - |
open? | boolean | Whether the modal is open. Note: if you set this, you must also set setIsOpen . | - | - |
setIsOpen? | (value ) => void | A function to set the modal’s open state. Note: if you set this, you must also set open . | - | - |
className? | string | - | - | FundProps .className |
fetchBuyOptions | FetchBuyOptions | - | - | FundProps .fetchBuyOptions |
fetchBuyQuote | FetchBuyQuote | - | - | FundProps .fetchBuyQuote |
inputType? | InputType | - | - | FundProps .inputType |
openIn? | "tab" | "popup" | - | - | FundProps .openIn |
submitLabel? | ReactNode | - | - | FundProps .submitLabel |
title? | ReactNode | - | - | FundProps .title |
country | string | - | - | FundProps .country |
locale? | string | - | - | FundProps .locale |
cryptoDecimalPlaces? | number | - | - | FundProps .cryptoDecimalPlaces |
cryptoCurrency | string | - | - | FundProps .cryptoCurrency |
fiatCurrency | string | - | - | FundProps .fiatCurrency |
fiatDecimalPlaces? | number | - | - | FundProps .fiatDecimalPlaces |
network | string | - | - | FundProps .network |
presetAmountInputs? | FundPresetAmountInputs | - | - | FundProps .presetAmountInputs |
subdivision? | string | - | - | FundProps .subdivision |
onError? | (e ) => void | - | - | FundProps .onError |
onStatus? | (lifecycleStatus ) => void | - | - | FundProps .onStatus |
onSuccess? | (result? ) => void | - | - | FundProps .onSuccess |
Property | Type | Description |
---|---|---|
activeMethod? | "email" | "sms" | The active auth method. |
HTMLAttributes
<HTMLButtonElement
>Property | Type | Description |
---|---|---|
step? | "credentials" | "verification" | If set, will render the back button for this step of the sign in flow, regardless of the context value. |
size? | ButtonSize | The size of the button. |
variant? | ButtonVariant | The variant of the button. |
SignInTitleAndDescriptionProps
.HTMLAttributes
<HTMLElement
>Omit
<HTMLAttributes
<HTMLElement
>, "children"
>Property | Type | Description |
---|---|---|
className? | string | The class name to apply to the component. |
alt? | string | The alt text for the image. |
src? | string | The source URL for the image. Uses the app logo by default. |
SignInTitleAndDescriptionProps
.HTMLAttributes
<HTMLElement
>Property | Type | Description |
---|---|---|
authMethod | "email" | "sms" | The auth method selected by the user. |
canResetOTP | boolean | Whether the user can request a new OTP. |
email | string | The email address of the user. |
error | | null | string | APIError | The error message or APIError object. |
flowId | string | The flow ID of the current sign-in flow. |
isPending | boolean | Whether the form state is pending. |
isSuccess | boolean | Whether the sign-in flow is successful. |
otp | string | The OTP code entered by the user. |
phoneNumber | string | The phone number of the user. |
step | "credentials" | "verification" | The current step of the sign-in flow. |
Property | Type |
---|---|
children? | ReactNode |
onSuccess? | () => void |
variant? | ButtonVariant |
Property | Type |
---|---|
children | ReactNode |
className? | string |
style? | CSSProperties |
theme? | Partial <Theme > |
colors-bg-primary
semantic color is used to define the background color for
a “primary” variant component. The colors-cta-primary-bg-default
component color inherits
from the colors-bg-primary
semantic color via CSS variables.
If you want to override the just the default background color of the primary cta, you can do so
by defining the colors-cta-primary-bg-default
token in the theme.
--cdp-web-
) in the keys.
Type Parameter |
---|
T |
Type Parameter |
---|
T extends Record <string , unknown > |
Property | Type |
---|---|
value | string | number |
modify? | object |
modify.type | "alpha" |
modify.value | number | string |
Type Parameter |
---|
T extends string |
Type Parameter |
---|
T |
Parameter | Type |
---|---|
params | { country : string ; subdivision? : string ; } |
params.country | string |
params.subdivision? | string |
Promise
<OnrampBuyOptionsResponse
>
Parameter | Type |
---|---|
params | { destinationAddress : string ; purchaseCurrency : string ; purchaseNetwork : string ; paymentAmount : string ; paymentCurrency : string ; paymentMethod : string ; country : string ; subdivision? : string ; } |
params.destinationAddress | string |
params.purchaseCurrency | string |
params.purchaseNetwork | string |
params.paymentAmount | string |
params.paymentCurrency | string |
params.paymentMethod | string |
params.country | string |
params.subdivision? | string |
Promise
<OnrampBuyQuoteResponse
>
Property | Type |
---|---|
state | FundState |
dispatch | Dispatch <FundAction > |
fetchBuyUrl | (params , onError? ) => Promise <string > |
Property | Type |
---|---|
code | string |
message | string |
Property | Type |
---|---|
value | string |
currency | string |
Property | Type | Description |
---|---|---|
paymentTotal | OnrampAmount | Object with amount and currency of the total fiat payment required to complete the purchase, inclusive of any fees. The currency will match the paymentCurrency in the request if it is supported, otherwise it falls back to USD. |
paymentSubtotal | OnrampAmount | Object with amount and currency of the fiat cost of the crypto asset to be purchased, exclusive of any fees. The currency will match the paymentCurrency . |
purchaseAmount | OnrampAmount | Object with amount and currency of the crypto that to be purchased. The currency will match the purchaseCurrency in the request. The number of decimals will be based on the crypto asset. |
coinbaseFee | OnrampAmount | Object with amount and currency of the fee changed by the Coinbase exchange to complete the transaction. The currency will match the paymentCurrency . |
networkFee | OnrampAmount | Object with amount and currency of the network fee required to send the purchased crypto to the user’s wallet. The currency will match the paymentCurrency . |
quoteId | string | Reference to the quote that should be passed into the initialization parameters when launching the Coinbase Onramp widget via the SDK or URL generator. |
onrampUrl? | string | Ready-to-use one-click-buy URL. Only returned when destination_address is provided in the request. |
Property | Type | Description |
---|---|---|
paymentCurrencies | OnrampPaymentCurrency [] | List of supported fiat currencies that can be exchanged for crypto on Onramp in the given location. Each currency contains a list of available payment methods, with min and max transaction limits for that currency. |
purchaseCurrencies | OnrampPurchaseCurrency [] | List of available crypto assets that can be bought on Onramp in the given location. |
Property | Type |
---|---|
name | string |
displayName | string |
chainId | string |
contractAddress | string |
iconUrl | string |
Property | Type |
---|---|
id | string |
limits | OnrampPaymentMethodLimit [] |
Property | Type |
---|---|
id | string |
min | string |
max | string |
Property | Type |
---|---|
id | string |
name | string |
symbol | string |
iconUrl | string |
networks | OnrampNetwork [] |
Property | Type |
---|---|
assetImageUrl | string |
assetName | string |
assetSymbol | string |
chainId | string |
--cdp-web-
) in the keys.
--cdp-web-
).