Skip to main content

React Integration

This guide demonstrates how to add the CoW Protocol SDK to a React application, including wallet connection and state management.

Installation

Setup SDK Instance

Create a shared SDK instance for use throughout your application.

Swap Component

A complete swap component with wallet integration:

App Component

Wrap your swap form in the main application:

Key Patterns

1. Dynamic Signer Updates

Update the SDK when the wallet changes:

2. Quote Updates

Automatically refresh quotes when parameters change:

3. Loading States

Track loading states for improved user experience:

Error Handling

Handle common errors gracefully:

TypeScript Types

Declare the ethereum window object:

Styling Example

Basic CSS for the swap form:

Next Steps

Last modified on March 4, 2026