Skip to content
Sign upLog in

How to add comment system like of replit or youtube using nodejs and replit DB?

Profile icon

Pls help!

I thought of using MongoDB but it is not possible on replit as I downloaded it on my PC. I cannot import and run it on replit.

ENOUGH! Mongo! your ded!!
How to make a comment system, like of replit's or youtube.


You are viewing a single comment. View All
Profile icon

What would it be a part of though? Would it be connected to specific pages, like with replit and youtube? How are users tracked? Who can see the comments? Please provide a Repl so that we can figure out these answers.

just to start off, just like a basic comment is going to include 1. a comment and 2. a username. I'd probably add like a comment id to that list too probably actually.

Repldb is pretty easy to use, you just use the store and get functions, providing a key (and a value when appropriate).

// set key"key", "value"); // get key repl_db.get("key");

You can see here I'm storing text, because, AFAIK, Repldb can only store text, but that should be fine as of course JSON objects are easily serialized using obj.toString() or JSON.stringify(obj) or whatever it is.

Again, if you want some suggestions that are more helpful to your situation, then please provide a Repl.

Profile icon

this is my goal -
there is an input(textarea), and a button to submit
the user types in the textarea and clicks submit.
The webpage adds a permanent text which was typed into the textarea
How can we do that on replit

Profile icon


First off, getting the Repl_db package is easy as any module import, but with a slightly weirder module name:

const Database = require("@replit/database");

Now that we have a the module, we make an actual database using the module as a class. (All of this stuff I'm talking about can found in the docs)

const db = new Database();

setting a value is really easy, but you can only store strings, and you need to always provide a key. For your purposes, I'd probably just use an ever-increasing number to signify it's order in the comments or something.

db.set("<KEY>", "<VALUE>").then(() => {});

getting a value is just as easy

db.get("<KEY>").then((value) => {});

For your purposes though, I'd use the list function instead, which lists all of the currently stored keys, and then just get them all in a row.

db.list().then((keys) => {});

I'm gonna leave the rest up to your already competent hands.


Profile icon

BRUH. how about the button. I cant understand :(
my body gave me this error -

npm error: no module named brain