This Next.js project is bootstrapped with create-next-app
and aims to integrate Nats Websocket with Next.js 13.
Before running this project, make sure you have a working NATS server and set up the required environment variables.
Create a .env
file in the root of your project with the following content:
NATS_SERVERS=<your_nats_server_address>
Then, run the preview server:
npm run preview
# or
yarn preview
# or
pnpm preview
# or
bun preview
Open http://localhost:3000 with your browser to see the result.
You can start sending messages with Nats CLI
nats pub foo "Message N°{{.Count}} on foo" --count=10 --sleep=250ms &
nats pub bar "Message N°{{.Count}} on bar" --count=10 --sleep=250ms &