Implement a blink client
Learn how you can implement an existing blink into your app.
Purpose of this guide is to teach you how to integrate an already existing blink into a blink client using the NextJS
framework. You will learn how the client works and what additional configuration steps are needed.
This guide will not show you how to implement a blink into an other backend service or AI agent. It will not teach you how to build a new blink also. If you want to build a blink, please start with our tip blink guide.
Level: Beginner
Requirements: Basic understanding of TypeScript and NextJS
Prerequisite
Code Editor of your choice (recommended Cursor or Visual Studio Code).
Node 18.x.x or above.
Basic TypeScript knowledge.
Testnet MON (Request MON via form if you haven't any).
Continuing from another tutorial?
If you have already finished one of our builder guides, you should have a running blink in a NextJS
project by now. If that's the case, you can skip the setup section and continue with the implementation part.
Initial Setup
Start by setting up a new NextJS
project and add some basic configuration.
Initialize the project
In your terminal, run the following command.
When prompted, configure your project with these settings:
✓ Ok to proceed? → Yes
✓ Would you like to use TypeScript? → Yes
✓ Would you like to use ESLint? → Yes
✓ Would you like to use Tailwind CSS? → Yes
✓ Would you like your code inside a src/
directory? → Yes
✓ Would you like to use App Router? → Yes
✓ Would you like to customize the import alias (@/*
by default)? → No
Install extra packages
Run the following command to install missing dependencies.
Start development server
The development server is used to start a local test environment that runs on your computer. It is perfect to test and develop your blink, before you ship it to production.
Coding Time 🚀
Now that we have our basic setup finished, it's time to open the editor and start coding. Please note that this tutorial requires you to have a working Blink implementation. For simplicity, this tutorial continues with the Blink that was built in the Tip Blink guide, but you can also use another Blink from our library.
If you use a different Blink than the Tip Blink, simply replace the localhost:3000 link with your chosen Blink's URL, for example, Lulo (https://blink.lulo.fi/actions?amount=${amount}&symbol=USDC).
Implement the provider
The provider is necessary to trigger wallet actions in the blink.
Create monad.ts file
This file contains a minimum config for the monad blockchain.
It is very likely that this data will be added to the viem/chains
package and become obsolete in the near future.
Create config for wagmi provider
This file is used to set the proper configurations for the WagmiProvider
in the next step.
Create provider
Create the provider that we can use to wrap around our app. Don't forget to use the “use client”;
at the top of the file if you are in a NextJS
project.
Wrap the provider
If you want your provider to be accessible throughout your app, it is recommended to wrap it around the children
element in your layout.tsx
.
Implement the client
Now that we have everything wrapped, we can start with the implementation of the client.
To do so open the page.tsx
file in your /src/app
folder.
Make a transaction
That's been it. Your blink should be up an running. To test it, visit localhost:3000 and click on a button or enter a custom amount that you want to donate.
Conclusion
In this guide, you have learned, how you can implement a blink client. The client serves as the user interface of the blink, that can be implemented in a website or app. You also learned that implementing a blink into a client only requires a link, not more. It is important to note that the blink doesn't have to be developed by yourself. There is already a huge library of blinks available these days, which you can discover on dial.to and use in your app.
This also means that if you want to implement a Jupiter swap functionality into your website, you don't have to implement it from scratch using their SDK or API. Instead you can just use the blink client and initiate it with their blink.
Last updated
Was this helpful?