I cant import mongoose on the frontend but it worked on the backend.
I have a separate directory for the backend. I have some code to add a couple users to my database.
Just today I found out about Mongoose's browser module while trying to solve similar problems to you. It's a very limited version of Mongoose but will let you do validation against schemas, for example, on the front-end. Sorry I only found this 6 months after your post.
Mongoose's browser library doesn't support mongoose.connect()
. It only supports schemas and document validation, it can't actually connect to MongoDB or save documents currently.