This tutorial shows how to use Upstash Kafka with Next.js.
In this post, we will implement the most simple application where we will publish messages to Kafka from a Next.js application.
First create a Next project with:
Then create an Upstash Kafka cluster and a topic as explained
here. In the cluster page, under the REST API
section, copy the producer code under the tab Javascript (fetch)
.
Paste the producer code to the pages/api/hello.js
as below:
Now you can test your code by running:
Check:
http://localhost:3000/api/hello
In the logs you should see the output of Kafka like below:
This tutorial shows how to use Upstash Kafka with Next.js.
In this post, we will implement the most simple application where we will publish messages to Kafka from a Next.js application.
First create a Next project with:
Then create an Upstash Kafka cluster and a topic as explained
here. In the cluster page, under the REST API
section, copy the producer code under the tab Javascript (fetch)
.
Paste the producer code to the pages/api/hello.js
as below:
Now you can test your code by running:
Check:
http://localhost:3000/api/hello
In the logs you should see the output of Kafka like below: