Next.js
Learn how to use the ZBD with Next.js and our Playground Starter Kit.
Playground Starter Kit
The ZBD + Next.js Playground Starter Kit is an application codebase that allows you to quickly get started with ZBD and Next.js. It includes two main sections: a ZBD API Playground and a Starter Kit for ZBD-powered Next.js applications.
Live Demo
Open the ZBD + Next.js Playground
GitHub Repository
View the source code.
Deploy to Vercel
1-click deploy your own instance of the ZBD Playground Starter Kit.
@zbd/node SDK
View detailed documentation for the Node.js SDK for ZBD API.
Next.js
To use ZBD with Next.js and complete this guide, you will need the following:
1. Create a Next.js project
Start with a brand new Next.js project. To begin run the following command and walk through the initializing steps:
2. Install @zbd/node Node.js SDK
Install ZBD:
3. Create Send and Receive API routes
Create a new file /app/api/receive/route.ts
and add the following code to create an API route that will receive instant Bitcoin payments:
Then create a new file /app/api/send/route.ts
and add the following code to create an API route that will send Bitcoin Lightning Address payments:
4. Run your Next.js server
Run the following command to start your Next.js server:
Using an API tool like Postman, you should be able to make a POST call to this endpoint and receive a JSON response with a payment request:
You’re looking for the data.invoice.request
property in the JSON response. It starts with lnbc1
and is the payment request anyone in the Bitcoin Lightning Network can use to pay you.
Using an API tool like Postman, you should be able to make a POST call to this endpoint and receive a JSON response with the payment success message:
You’re looking for the status
of completed
to know that the payment settled successfully.
processing
. This is expected — use the callbackUrl
property to receive updates about your payments.5. Try it yourself
You can now send and receive instant Bitcoin payments using Next.js + ZBD!
Was this page helpful?