Quickstart
Get up and running with Compound React in minutes
This guide will help you quickly get started with Compound React by walking through a simple example of setting up the provider and using some basic hooks.
Basic Setup
First, make sure you have installed Compound React as described in the Installation guide.
Setting Up the Provider
To use the hooks provided by Compound React, you need to wrap your application with the CompoundProvider
component:
Connecting to a Specific Network
You can specify which network to connect to by passing the network
prop to the CompoundProvider
:
Connecting to a Specific Market
You can also specify which market to connect to by passing the market
prop:
Using Hooks
Once you have set up the provider, you can start using the hooks in your components.
Getting Asset Information
To get information about an asset, you can use the useGetAssetInfo
hook:
Getting User Account Information
To get information about the user’s account, you can use the useGetAccountInfo
hook:
Supplying Collateral
To supply collateral to the protocol, you can use the useSupplyCollateral
hook:
Using UI Components
Compound React also provides a set of ready-to-use UI components that work seamlessly with the hooks. These components handle loading states, error handling, and data formatting for you.
Basic UI Component Example
Here’s a simple example of using the AssetInfoCard
and InterestRateDisplay
components:
Using the Dashboard Component
For a more comprehensive UI, you can use the CompoundDashboard
component which combines multiple components into a tabbed interface:
The dashboard includes tabs for:
- Overview (position summary, interest rates, market stats)
- Supply & Borrow
- Assets
- Transaction History
Customizing Components
All UI components accept a className
prop that allows you to customize their appearance using Tailwind CSS classes:
For more information on customizing the components, see the UI Components section.
Complete Example
Here’s a complete example that combines all of the above:
Next Steps
Now that you have a basic understanding of how to use Compound React, you can explore the Hooks section to learn about all the available hooks and how to use them in your application.