---
title: "Comment by nandan vasista on \"🗃️ How to use Mongoose with Next.js for MongoDB?\" | Hashnode"
description: "Server Error TypeError: (0 , mongoose WEBPACK_IMPORTED_MODULE_0 .model) is not a function This error happened while generating the page. Any console logs will b"
url: "https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2/comment/636150148dbe21712c7dc004"
---

[Discussion](https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2)

Comment [🗃️ How to use Mongoose with Next.js for MongoDB?](https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2)

[nandan vasista](https://hashnode.com/@nandan910)

[Nov 1, 2022](https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2/comment/636150148dbe21712c7dc004)

Server Error TypeError: (0 , mongoose**WEBPACK\_IMPORTED\_MODULE\_0**.model) is not a function

This error happened while generating the page. Any console logs will be displayed in the terminal window. --error above-- --code below--

import { Schema, model, models } from "mongoose";

const UserSchema = new Schema({ displayName: { type: String, required: true }, email: { type: String, required: true, unique: true }, phone: { type: String, unique: true }, password: { type: String }, pro: { type: Boolean, default: false }, author: { type: Boolean, default: false }, photoURL: { type: String }, }); const User = models.User || model("User", UserSchema);

export default User;
