This is a Next.js app for live comments built to showcase Ably LiveSync's MongoDB connector. The system is simple: in order to leave comments, replies and reaction, a request is made to MongoDB. Ably LiveSync utilises MongoDB Change Streams to listen to database changes within MongoDb and sends messages over Ably to a destination channel.
First we need to set-up the MongoDB server. To do this, either create an account at MongoDB's website or follow the instructions in this terraform docs page. You should create a collection called comments and ably. You should ensure the the Network Access is set up to recieve on all IPs (0.0.0.0/0) and that a role and user has been created that satisfies these database permissions for LiveSync.
Secondly, we should set up the Ably LiveSync MongoDB rule. You can use this via the Control API, or through the Ably dashboard. The 'pipeline' setting is in the ably_pipeline.json file.
To run the development server:
npm install
npm run devOpen http://localhost:3000 with your browser to see the result.
- Add comments
- Reply to comments (one layer of nested replies)
- React to comments and replies with emojis
This project is licensed under the MIT License.