Getting Started

Install Mongoose Studio

Get up and running with Mongoose Studio in minutes. Choose your platform below.

1. Install the Package

npm install @mongoosejs/studio

2. Integrate with Your App

Integrate Mongoose Studio as middleware in your Express app. The following will mount Mongoose Studio at /studio. Remember to use await!

const mongoose = require('mongoose');
const studio = require('@mongoosejs/studio/express');
// other code...

// Mount Mongoose Studio on '/studio'.
// If you want a different path, change '/studio' to your desired path.
// Make sure to use await!
app.use('/studio', await studio('/studio/api', mongoose));

Mongoose Connections

If you create a new Mongoose connection using mongoose.createConnection(), you can pass it to Mongoose Studio as follows:

const mongoose = require('mongoose');
const studio = require('@mongoosejs/studio/express');
// other code...

// Create a new Mongoose connection
const connection = mongoose.createConnection('mongodb://localhost:27017/mydb');

// Mount Mongoose Studio on '/studio'.
app.use('/studio', await studio('/studio/api', connection));

Mongoose Studio currently only supports a single Mongoose connection.

Configuration

If you have a Mongoose Studio Pro API key or wish to use advanced features, like providing your own OpenAI key, pass options as follows:

const opts = {
  apiKey: process.env.MONGOOSE_STUDIO_API_KEY, // optional for Pro
  model: 'gpt-4o-mini', // optional ChatGPT model
  openAIAPIKey: process.env.OPENAI_API_KEY,          // optional for chat
  anthropicAPIKey: process.env.ANTHROPIC_API_KEY,    // optional for chat
  googleGeminiAPIKey: process.env.GOOGLE_GEMINI_API_KEY // optional for chat
};

app.use('/studio', await studio('/studio/api', mongoose, opts));

Accessing Mongoose Studio

  • In local development, visit http://localhost:3000/studio (or the path you choose).
  • In production, Studio will be at your-app.com/studio.

Deploy Mongoose Studio alongside your Next.js app on Vercel in two steps.

Add withMongooseStudio to next.config.js

import withMongooseStudio from '@mongoosejs/studio/next';

// Mount Mongoose Studio frontend on /studio
export default withMongooseStudio({
  // Your Next.js config here
  reactStrictMode: true,
});

Create pages/api/studio.js

Add the Mongoose Studio API handler to your Next.js project. If your app uses the Mongoose global (i.e. import mongoose from 'mongoose'), you can pass mongoose directly:

import mongoose from 'mongoose';
import studio from '@mongoosejs/studio/backend/next';

const handler = studio(mongoose, {
  apiKey: process.env.MONGOOSE_STUDIO_API_KEY, // required for auth
});

export default handler;

Custom Connection

If your app uses a separate connection via mongoose.createConnection(), pass the connection as db and optionally provide a connectToDB function to open the connection on demand:

import db from '../../src/db';
import studio from '@mongoosejs/studio/backend/next';

const handler = studio(db, {
  apiKey: process.env.MONGOOSE_STUDIO_API_KEY, // required for auth
  connection: db,
  connectToDB: async () => {
    // Your connection logic here, e.g.:
    // await db.openUri(process.env.MONGODB_URI);
  },
});

export default handler;

Configuration

To enable AI chat features, pass your own API keys:

const handler = studio(mongoose, {
  apiKey: process.env.MONGOOSE_STUDIO_API_KEY, // required for auth
  model: 'gpt-4o-mini', // optional ChatGPT model
  openAIAPIKey: process.env.OPENAI_API_KEY,          // optional for chat
  anthropicAPIKey: process.env.ANTHROPIC_API_KEY,    // optional for chat
  googleGeminiAPIKey: process.env.GOOGLE_GEMINI_API_KEY // optional for chat
});

Deploy

Push to your Vercel-connected repo and you're live! Studio will be available at your-app.vercel.app/studio.

3. Next Steps

  • Local Auth: By default, authentication is not enabled. For production security and role management, check out Mongoose Studio Pro.
  • Demo: Test drive with the IMDB demo.
  • Source: Check out the GitHub repo for examples and advanced setup.
  • Request a Feature (or Report a Bug): Open an issue on GitHub Issues.

Need Help?

Join our Discord community for support, questions, and feature discussions.

Get Support on Discord