Receiving instant Bitcoin payments on Vercel
Learn how to receive Bitcoin using Vercel Edge Functions.
Prerequisites
To complete this guide, you will need the following:
1. Create a Next.js Project
Follow the prompts on the create-next-app CLI to create a new project, and then change into the directory of your project.
2. Write an Edge Function
Create a new file in the app/api/request/route.ts
that creates a Bitcoin Lightning Charge (payment request) with the following code:
3. Create payment request locally
Run function locally:
Opening your browser to the following URL: http://localhost:3000/api/request
should return a JSON response with a payment request.
You can also test this using curl command:
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.
4. Create payment request in production
Deploy your project to Vercel:
Opening your browser to the following URL: https://project-name.vercel.app/api/request
should now return this in production.
You can also test this using curl command:
5. Try it yourself
You can now begin receiving instant Bitcoin payments on the edge with Vercel + ZBD!
Was this page helpful?