Dynamic Wagmi Connector Setup Guide
Use @dynamic-labs/wagmi-connector to bridge Dynamic wallet authentication with Wagmi hooks in a Next.js app. This setup keeps wallet login, chain state, and React query wiring aligned so Gizmolab UI components can rely on one clean provider stack.
What the Dynamic Wagmi connector does
@dynamic-labs/wagmi-connector links Dynamic's wallet connection flow with Wagmi's React provider and hook model. That gives you one setup where Dynamic handles auth and wallet UX, while Wagmi powers account state, chain state, and downstream wallet-aware components.
The connector is useful when your app needs both a polished wallet entry point and a stable hook layer for account-dependent features like chain switching, portfolio views, gated dashboards, or transaction flows.
- Dynamic handles login and wallet connection UX.
- Wagmi powers hooks such as
useAccount. - React Query supports Wagmi's async data layer.
- Gizmolab UI components can plug into one consistent provider stack.
1. Install the required packages
Start with the same package set used across the current Dynamic-based docs and component examples:
This covers the Dynamic provider, Ethereum wallet connectors, the Wagmi bridge, Wagmi itself, and the React Query dependency Wagmi expects.
After setup, you can move into wallet-aware UI patterns such as Chain Selector, Crypto Product Card, NFT Portfolio Dashboard, and Polymarket Widget.
2. Add your Dynamic environment ID
Dynamic needs a public environment ID available at runtime. Add it to a project-level .env file as NEXT_PUBLIC_DYNAMIC_ID.
If this value is missing, the wallet widget may render partially or fail during initialization. Restart the app after updating environment variables so the client bundle sees the new value.
3. Create one shared Wagmi config
Keep chain definitions and transports in one exported config. A single config prevents route-level drift and makes provider wiring much easier to reason about.
Practical rules that prevent most connector issues:
- Keep every supported chain in one exported
chainsarray. - Add a transport entry for every chain you include.
- Reuse one shared
wagmiConfiginstead of creating multiple configs. - Leave
multiInjectedProviderDiscoverydisabled if you want behavior aligned with the current Gizmolab setup.
4. Wrap providers in the correct order
Provider order matters. The safest baseline is Dynamic first, then Wagmi, then React Query, with DynamicWagmiConnector wrapping the children that need wallet-aware hooks.
This order matters because:
- Dynamic initializes wallet auth and connection UX.
- Wagmi receives the shared chain and transport config.
- React Query supports Wagmi's data lifecycle.
- The connector bridges the authenticated wallet session into Wagmi-aware children.
5. Mount the provider high in your app
In a Next.js App Router project, wrap your shared layout with the context provider so wallet-aware routes all use the same session and chain state.
6. Verify the connector before adding more UI
Before you add more complex components, confirm that the wallet widget renders and Wagmi can see account state.
If both checks work, the Dynamic Wagmi connector is usually wired correctly.
Common setup mistakes
Missing NEXT_PUBLIC_DYNAMIC_ID
Confirm the variable name is exact, the value is present in the right environment file, and the dev server was restarted after the change.
Client and server boundaries are mixed
Files that initialize Dynamic or Wagmi providers must be client components. Put "use client" at the top of the provider file.
A chain exists without a matching transport
If a chain is added to the config without a corresponding transport entry, wallet connectivity can become unreliable or incomplete.
Providers are wrapped in the wrong order
When the provider stack is rearranged, hooks can fail silently and connected state may not propagate to child components.
Next docs and components to pair with this setup
After the connector is stable, use the broader Install Dynamic guide for the base wallet flow, then move into component-specific usage for wallet-aware product experiences.
- Chain Selector for network switching UX.
- Crypto Product Card for wallet-aware commerce flows.
- NFT Portfolio Dashboard for holdings and collection views.
- Polymarket Widget for advanced trading-style wallet integrations.