Overview
ThePolygonKitProvider is the root component that provides blockchain connectivity and state management to your entire application. It sets up wagmi, React Query, and WalletConnect integration.
Basic Usage
Wrap your application with the provider:Configuration Options
The provider accepts an optionalconfig prop for customization:
chains
An array of blockchain networks your app supports. Defaults to Polygon PoS, Polygon Amoy, and Polygon zkEVM.Available Polygon Chains
Available Polygon Chains
- polygon (137) - Polygon PoS Mainnet
- polygonAmoy (80002) - Polygon Amoy Testnet
- polygonZkEVM (1101) - Polygon zkEVM Mainnet
- polygonZkEvmTestnet (1442) - Polygon zkEVM Testnet
- polygonMumbai (80001) - Polygon Mumbai Testnet (deprecated)
projectId
Your WalletConnect Project ID. Required for WalletConnect functionality.Get a Project ID
Learn how to create a WalletConnect Project ID
appName
The name of your application displayed in wallet connection modals.appDescription
A description of your application shown to users.appUrl
Your application’s URL.appIcons
An array of icon URLs for your application.Complete Example
Here’s a fully configured provider:Environment Variables
Store sensitive configuration in environment variables:- Next.js
- Vite
- Remix
.env.local
Default Configuration
If you don’t provide a config, PolygonKit uses these defaults:The default Project ID is for development only. Create your own for production apps.
React Query Configuration
PolygonKit uses TanStack React Query internally. The provider automatically sets up a QueryClient with sensible defaults:Wagmi Configuration
The provider creates a wagmi config with:- WalletConnect connector
- Injected wallet connector (MetaMask, etc.)
- Coinbase Wallet connector
- Public RPC transports for all chains
Best Practices
Use Environment Variables
Use Environment Variables
Store your WalletConnect Project ID and other sensitive data in environment variables, not in your code.
Limit Chains
Limit Chains
Only include the chains your app actually uses. This improves UX and reduces unnecessary network requests.
Provide Metadata
Provide Metadata
Set appName, appDescription, and appIcons to give users context about your app when connecting their wallet.
Test Multiple Frameworks
Test Multiple Frameworks
If supporting multiple frameworks (Next.js, Vite, Remix), test the provider configuration in each environment.
Troubleshooting
Provider not found error
Provider not found error
Make sure
PolygonKitProvider is wrapping your entire app at the root level, not inside specific pages or components.Invalid Project ID
Invalid Project ID
Verify your WalletConnect Project ID is correct and has not been revoked. Create a new one if needed.
Chains not switching
Chains not switching
Ensure all chains you want to support are included in the
chains array configuration.Chain Configuration
Learn more about configuring chains
WalletConnect Setup
Set up WalletConnect Project ID