Wafer Connect

https://github.com/saklani/wafer-connect

Getting Started

Installation

Install wafer-connect and its peer dependencies @wagmi/core and viem.

npm install wafer-connect @wagmi/core viem

WalletConnect ProjectId is required since wafer-connect only supports WalletConnect v2.

Learn More: walletconnect.com

Import & Initialize

Import from wafer-connect and @wagmi/core

import { configureChains, createConfig } from "@wagmi/core";
import { mainnet } from "@wagmi/core/chains";
import { publicProvider } from "@wagmi/core/providers/public";
import ConnectButton, { getDefaultConnectors } from "wafer-connect";

Initialize @wagmi/core client and get default connector.


const { chains, publicClient } = configureChains(
  [mainnet],
  [publicProvider()]
);
const { connectors, wallets } = getDefaultConnectors({
  appName: "my_dapp",
  projectId: "...", // WalletConnect ProjectId
  chains,
});

createConfig({ connectors, publicClient });
<ConnectButton/>

Full Example

<script>
  import { configureChains, createConfig } from "@wagmi/core";
  import { mainnet } from "@wagmi/core/chains";
  import { publicProvider } from "@wagmi/core/providers/public";
  import ConnectButton, { getDefaultConnectors } from "wafer-connect";

  const { chains, publicClient } = configureChains(
    [mainnet],
    [publicProvider()]
  );

  const { connectors, wallets } = getDefaultConnectors({
    appName: "my_dapp",
    projectId: "...", // WalletConnect ProjectId
    chains,
  });

  createConfig({ connectors, publicClient });
</script>

<header>
  <div />
  <ConnectButton />
</header>

<style>
  header {
    display: flex;
    justify-content: space-between;
    padding: 8px;
  }
</style>