@walletconnect/wagmi-connector
v1.0.3
Published
WalletConnect connector for wagmi
Readme
@walletconnect/wagmi-connector
Official WalletConnect connector for wagmi.
Installation
# Using pnpm
pnpm add @walletconnect/wagmi-connector
# Using npm
npm install @walletconnect/wagmi-connector
# Using yarn
yarn add @walletconnect/wagmi-connector
# Using bun
bun add @walletconnect/wagmi-connectorUsage
Basic Setup
import { createConfig, http } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { injected } from 'wagmi/connectors'
import { walletConnect } from '@walletconnect/wagmi-connector'
export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
walletConnect({
projectId: 'YOUR_WALLETCONNECT_PROJECT_ID' // dashboard.reown.com
}),
],
transports: {
[mainnet.id]: http(),
},
})Configuration Options
walletConnect({
projectId: string // Required: Your WalletConnect project ID
showQrModal?: boolean // Optional: Show QR modal (default: true)
isNewChainsStale?: boolean // Optional: Treat new chains as stale (default: true)
metadata?: { // Optional: App metadata
name: string
description: string
url: string
icons: string[]
}
qrModalOptions?: { // Optional: QR modal configuration
enableMobileFullScreen?: boolean
}
})Migration from wagmi/connectors
If you're migrating from the built-in wagmi connector:
Before:
import { walletConnect } from 'wagmi/connectors'After:
import { walletConnect } from '@walletconnect/wagmi-connector'That's it! The API is exactly the same.
Local Development & Testing
Building the Package
# Install dependencies
pnpm install
# Build the package
pnpm build
# Clean build artifacts
pnpm cleanTesting Locally with pnpm link
In the connector package directory (
~/Code/wagmi-connector):# Build the package pnpm build # Link it globally pnpm link --globalIn your test application:
# Link the connector pnpm link --global @walletconnect/wagmi-connectorUpdate your imports:
// Replace wagmi/connectors import import { walletConnect } from '@walletconnect/wagmi-connector'Test the functionality:
- Run your dev server
- Test WalletConnect connection
- Verify all features work correctly
Unlinking After Testing
# In your test app
pnpm unlink @walletconnect/wagmi-connector
# In the connector package
pnpm unlink --globalRequirements
- wagmi: ^2.0.0
- viem: ^2.0.0
- @wagmi/core: ^2.22.0
- TypeScript: >=5.0.4 (optional)
TypeScript
This package is built with TypeScript and includes type definitions. All types are exported from the main entry point:
import { walletConnect, type WalletConnectParameters } from '@walletconnect/wagmi-connector'API Reference
walletConnect(parameters)
Creates a WalletConnect connector instance.
Parameters
projectId(required): Your WalletConnect Cloud project ID. Get one at cloud.walletconnect.comshowQrModal(optional): Whether to show the QR modal for connection. Default:trueisNewChainsStale(optional): How to handle newly added chains. Default:truetrue: Disconnect and require reconnection when new chains are addedfalse: Attempt to continue connection (may error if wallet doesn't support dynamic chains)
metadata(optional): Application metadata shown in wallet during connectionqrModalOptions(optional): Configuration options for the QR modalenableMobileFullScreen: Enable full-screen mode on mobile devices
Returns
A wagmi connector instance that can be used in createConfig.
Examples
With Custom Metadata
walletConnect({
projectId: 'YOUR_PROJECT_ID',
metadata: {
name: 'My DApp',
description: 'My awesome decentralized app',
url: 'https://myapp.com',
icons: ['https://myapp.com/icon.png']
}
})Without QR Modal
walletConnect({
projectId: 'YOUR_PROJECT_ID',
showQrModal: false
})Handling Dynamic Chains
walletConnect({
projectId: 'YOUR_PROJECT_ID',
isNewChainsStale: false // Allow dynamic chain additions
})With QR Modal Options
walletConnect({
projectId: 'YOUR_PROJECT_ID',
qrModalOptions: {
enableMobileFullScreen: true // Enable full-screen on mobile
}
})Troubleshooting
"ProviderNotFoundError"
Make sure you've installed @walletconnect/ethereum-provider:
pnpm add @walletconnect/ethereum-providerTypeScript Errors
Ensure you have the correct peer dependencies installed:
pnpm add wagmi viem @wagmi/coreConnection Issues
- Verify your WalletConnect project ID is correct
- Check that your chains are properly configured in wagmi
- Ensure your RPC endpoints are accessible
License
See LICENSE.md for details. This project is licensed under the WalletConnect Community License Agreement.
Acknowledgments
Portions © 2025 Reown, Inc. All Rights Reserved
This project includes code derived from wagmi, which is licensed under the MIT License. See NOTICE for full attribution details.
Links
Contributing
This package is maintained by WalletConnect. We welcome contributions! Please follow these guidelines:
Development Setup
Clone the repository:
git clone https://github.com/walletconnect/wagmi-connector.git cd wagmi-connectorInstall dependencies:
pnpm installBuild the package:
pnpm build
Running Tests
# Run tests once
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverageCode Quality
Before submitting a PR, ensure your code passes all checks:
# Type checking
pnpm typecheck
# Linting
pnpm lint
# Format code
pnpm format
# Check formatting
pnpm prettier:checkPull Request Process
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run all tests and linting checks
- Commit your changes using Conventional Commits
- Push to your fork and submit a Pull Request
Release Process
This project uses Changesets for version management.
- Make your changes
- Add a changeset:
pnpm changeset - Commit the changeset file
- When merged to main, a PR will be automatically created to bump versions and update the changelog
- Merging the version PR will automatically publish to npm
CI/CD
The repository uses GitHub Actions for continuous integration:
- PR Checks: Runs on all pull requests, testing build, linting, type checking, and tests on Node.js 18.x and 20.x
- Publish: Automatically publishes to npm when version PRs are merged to main
- Canary Releases: Manual workflow for publishing canary versions
Issues and Feature Requests
Please open an issue in the repository to report bugs or request features.
