Dev48
Language
  • About
  • Services
  • Industries
  • Technologies
  • Articles
  • Contacts
Book a call
    Home/Articles/Using mongodb with mongoose in nuxt
Dev48
info@dev48.org+375 29 320-40-96WhatsApp@isky_by

© 2026 · All rights reserved.

Using MongoDB with Mongoose in Nuxt

Source: Telerik Blogs•October 2, 2026 at 10:09 PM

Using MongoDB with Mongoose in Nuxt

Learn how to use Mongoose object modeling with MondoDB Atlas and Nuxt.

Learn how to use Mongoose object modeling with MondoDB Atlas and Nuxt.

Building a Todo app with Nuxt and Mongoose is extremely easy! I’ve been building with Firebase for years, but this was almost easier!

TL;DR

This app connects to MongoDB Atlas and uses nuxt-mongoose to easily configure a document schema for a todo app. The app is easy to create thanks to the Mongoose JS.

Nuxt App Setup

📝 Make sure to install Tailwind.

Create a Mongo Atlas Account

Log in to MongoDB and create an account. You can get your database string under “Connect” once you sign up.

Click the “Drivers” to get your connection string.

.env

Set your connection string in your nuxt enivornment variable inside the .env file at the root.

Install Nuxt Mongoose

Install Nuxt Mongoose with:

And configure nuxt.config.ts:

Create the Todo Model

You can read about the schema at official mongoose guide.

📝 The timestamps options auto configures updatedAt and createdAt for you on each document.

Configure Todo API Routes

We need to CRUD the Todo Documents.

Create Todo

The model allows use to easily use the create() command to create a document. The h3 package allows us to handle the errors with createError() and get data with readBody().

Get Todos

We want to sort the data by createdAt descending, and use lean() to only get the field data, not the meta data.

Delete Todo

We delete by ID.

Update Todo

We update the document by ID.

📝 returnDocument: ‘after’ – We want the state after the change.

📝 runValidators: true – The update must match the schema rules.

Todo Composable

We can call the API routes and use good separate of concerns by creating a Todo Composable.

Frontend Types

And import them in the composable.

📝 deletingId and togglingId are used just like isSubmitting to validate the fetch process.

📝 You could also use Nuxt Form Actions, although I just went straight $fetch here.

Todo Components

Our parent component displays the Todo Form Component and the Todo List Component after Prop Drilling.

Parent

📝 I usually like to use shared state with useState, but I found prop drilling to be cleaner here.

Todo Form

This displays the add a todo form.

When submitted, we must reset the form and show a message if necessary.

Todo List

Every time there is a refresh, we list the todos.

📝 Notice the arial-label and title for accessibility.

📝 deletingId and togglingId are used to handle state changes.

Database

Once you run the app, you will see your data in Atlas.

Final Review

I honestly thought configuring Mongoose was going to be a pain. I have been building with Firebase since Firestore was released, and I thought Mongo DB would be different. has come a LONG way, and pretty much configures it for you.

The only negative with mongoose is the lack of built-in authentication support. There is, however, a better-auth adapter. You also can’t do anything on the client/browser like you can with Firebase or Supabase, but these days I’m OK with that!

Honestly, this was fun to build.

Repo: GitHub

← All articles

What this article says

More in Software Development

All →
From edge infrastructure to intelligence at scale
HCLTech

From edge infrastructure to intelligence at scale

From systems to service: Building an employee-first workplace with Agentic AI
HCLTech

From systems to service: Building an employee-first workplace with Agentic AI

Service Desk Best Practices and KPIs for a Modern Support Operation
HCLTech

Service Desk Best Practices and KPIs for a Modern Support Operation

UX audit: A step-by-step guide with a working checklist
Netguru

UX audit: A step-by-step guide with a working checklist

An early look at the Grafana UI refresh: Building a clearer, more consistent user experience
Grafana Labs

An early look at the Grafana UI refresh: Building a clearer, more consistent user experience

LinkedIn Connected Apps 1.2: Clearer Level System, Visible Progress, and Direct Answers About Privacy
JetBrains

LinkedIn Connected Apps 1.2: Clearer Level System, Visible Progress, and Direct Answers About Privacy

More from Telerik

5 Agent Skills for Production Web Apps: Teach Your AI Coding Agent to Slow Down
Telerik

5 Agent Skills for Production Web Apps: Teach Your AI Coding Agent to Slow Down

Create a Cute Animal UI in .NET MAUI with Telerik UI Controls
Telerik

Create a Cute Animal UI in .NET MAUI with Telerik UI Controls

Is Convex Better Than Firebase?
Telerik

Is Convex Better Than Firebase?

How Do Software Development Teams Work?
Telerik

How Do Software Development Teams Work?

A Better v-model with defineModel
Telerik

A Better v-model with defineModel

Building Trustworthy AI Experiences
Telerik

Building Trustworthy AI Experiences