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
For this guide we will be making use of the App Router inside of Next.js.
app/api/send/route.ts that makes a payment to a Lightning Address (e.g. [email protected]) with the following code:
3. Send payment locally
Run function locally:https://example.com/api/send should return a JSON response with the payment sent message.
You can also test this using curl command:
status of completed to know that the payment settled successfully.
Payments in the Lightning Network are asynchronous so you may see a response stating the payment is
processing. This is expected — use the callbackUrl property to receive updates about your payments.4. Send payment in production
Deploy your project to Vercel:https://project-name.vercel.app/api/send should now return this in production.
You can also test this using curl command: