React Chat Example
This example chat application demonstrates the core concepts and capabilities of the XMTP Client SDK. It is built with React, Next.js, and the
xmtp-js client library. The application is capable of sending and receiving messages via the XMTP Labs development network, with no performance guarantees and notable limitations to its functionality.
All wallets and messages are forcibly deleted from the development network on Mondays.
The XMTP protocol is in the early stages of development. This software is being provided for evaluation, feedback, and community contribution. It has not undergone a formal security audit and is not intended for production applications. Significant breaking revisions should be expected.
Add your Infura ID to
.env.local in the project's root.
If you do not have an Infura ID, you can follow these instructions to get one.
This example comes preconfigured with an Infura ID provided for demonstration purposes. If you plan to fork or host it, you must use your own Infura ID as detailed above.
Install the package
Run the development server
npm run dev
Open http://localhost:3000 with your browser to see the application.
Web3Modal is used to inject a Metamask, Coinbase Wallet, or WalletConnect provider through
ethers. Methods for connecting and disconnecting are included in WalletContext alongside the provider, signer, wallet address, and ENS utilities.
In order to use the application's chat functionality, the connected wallet must provide two signatures:
- A one-time signature that is used to generate the wallet's private XMTP identity
- A signature that is used on application start-up to initialize the XMTP client with that identity
The application utilizes the
xmtp-js Conversations abstraction to list the available conversations for a connected wallet and to listen for or create new conversations. For each convesation, it gets existing messages and listens for or creates new messages. Conversations and messages are kept in a lightweight store and made available through XmtpContext alongside the client and its methods.
The application's functionality is limited by current work-in-progress on the
Messages cannot yet be directed to wallets that have not used XMTP
The client will throw an error when attempting to lookup an address that does not have an identity broadcast on the XMTP network.
This limitation will be mitigated very soon by the example application's UI, and resolved soon via improvements to the
xmtp-js library that will allow messages to be created even if the intended recipient has not yet generated its keys.