Skip to main content
This guide shows you how to integrate the CoW Protocol SDK into a React application with proper wallet connection and state management.

Installation

Setup SDK Instance

Create a shared SDK instance that can be used throughout your app.
cowSdk.ts

Swap Component

Here’s a complete swap component with wallet connection:
SwapForm.tsx

App Component

Wrap your swap form in the main app:
App.tsx

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 better UX:

Error Handling

Handle common errors gracefully:

TypeScript Types

Declare the ethereum window object:
ethereum.d.ts

Styling Example

Basic CSS for the swap form:
App.css

Next Steps