Are you looking for a quick and easy way to set up a development environment with MongoDB without installing anything on your local machine? Look no further than Project IDX, Google’s new web-based IDE. You can use the new MongoDB template in IDX to create a workspace with a running MongoDB instance and start developing in seconds—all for free!
What is Project IDX?
Project IDX is a modern web-based development environment with built-in AI assistance. Each IDX workspace runs on a virtual machine hosted in Google Cloud. IDX’s code editor is based on Code OSS, the open-source project powering VS Code. In addition to the code editor, IDX provides Android emulators, VS Code extensions, integration with Firebase Hosting, and more.
One of the standout features of IDX is its built-in AI assistance powered by Google Gemini. This functionality offers inline, project-aware code suggestions and code generation, along with a chat agent that can perform actions within your workspace. MongoDB has worked closely with the Google Gemini Code Assist team to fine tune and train Gemini Code Assist on MongoDB best practices, to provide developers intelligent code completions and enhanced productivity for MongoDB-based projects.
IDX also comes with a set of services that you can enable when creating a new workspace. For example, you can turn on the MongoDB service which sets up a MongoDB Community Edition database instance in the VM of your workspace. To make it even easier for you to get started, we built a MongoDB template for IDX.
MongoDB template for IDX
Project IDX provides officially supported templates that you can use to quickly scaffold a workspace with a specific setup and configuration. MongoDB collaborated with the IDX team to build a MongoDB template that comes with a database instance running in the virtual machine.
Let’s head to IDX and try the template. You can register and create a limited number of workspaces for free.
Once you’re registered and signed in, go to “See all templates.”
Select “Databases” from the left sidebar, and then “MongoDB.”
The template offers three environments:
- Node.js database starter script
- Express REST API
- Flask REST API
Every environment has sample code connecting to the locally running MongoDB instance.
Name your workspace, select “REST API with Express and MongoDB” from the dropdown, and create the workspace. Your new workspace will take up to a minute to provision and load.
Exploring the project
The Express flavor of the workspace comes with a simple REST API. The API has a /users endpoint allowing you to execute CRUD operations on a Users database. You can explore the scripts from the file structure on the left.
The API is already running when you open your workspace. You can find the process by opening the second terminal tab at the bottom.
Open another tab using the + (plus) icon on the top right and send a POST request to the users endpoint to insert a new user.
curl -X POST http://localhost:3000/users \
-H "Content-Type: application/json" \
-d '{
"name": "Amy",
"email": "amy@dunne.com"
}'
Then, send a GET request to get all users:
curl http://localhost:3000/users
You should get a response with the document you just inserted. Notice that the document also has an _id field along with the fields you provided. MongoDB generated this field automatically to use it as a unique identifier for your document.
Interacting with the local MongoDB database
The MongoDB instance is running in the background. You can interact with it through the MongoDB Shell that is also installed in the workspace.
If you open the config.js file, you will notice that the server is connecting to an instance running locally:
uri: 'mongodb://localhost:27017/',
In the same file, you will also notice the database and collection names—my_database and users.
Open a new terminal emulator from the bottom using the + icon and run the mongosh command to connect to the local instance:
mongosh
Then, run the following commands to find the document you inserted:
use my_database
db.users.find()
While this is fun, usually it’s much easier to explore the data with the MongoDB extension for VS Code. Don’t forget that IDX is built on the same open-source project as VS Code, which means you can add any VS Code extension to your workspace.
The MongoDB template comes with the MongoDB extension by default. The extension will be installed automatically when you create a new workspace using this template. You may have seen the extension welcome screen when you created the workspace. If you didn’t see it, you can bring it back up again by clicking on the MongoDB leaf logo in the left sidebar, and then “Add Connection.” From the welcome screen, select “Connect” under the “Connect with Connection String” section.
The connection string for the MongoDB instance running locally in your workspace is mongodb://localhost:27017. Once you type it in and hit enter, the extension will connect to the local instance. You can explore the data from the connection tab on the left. Expand the "my-database" database and the "users" collection to view the document you inserted earlier.
Connecting to external MongoDB databases
A local database instance is only useful if you’re the sole developer in the project. The instance will be running for a short period while you have the IDX editor open. It’s ideal if you’re looking for a quick proof of concept and you don’t want to set up anything in your local environment.
Collaborating with others is much more practical with a database running externally. For example, you can create a cluster in MongoDB Atlas and connect to it. To set up a free database cluster, follow the instructions in the MongoDB documentation.
After that, just update the connecting string in the config.js file, and you’re good to go!
AI assistance
One area where IDX shines compared to other online editors is the integrated AI code assistance. The assistant, powered by Gemini, understands the context of your entire project and can propose code changes to your codebase. Let’s give it a try.
To open the Gemini chat, find the “Gemini” button at the bottom of the editor. If you don’t see it, you may need to manually install the Gemini extension, or it could be unavailable in your region. In this case, check the list of available regions.
Then, click the + icon and start a “New Interactive Chat.” While inserting a new user with the POST endpoint, I noticed that I didn’t get a message for success. Let’s ask Gemini to fix that with the following prompt:
“Improve my user creation endpoint to return a message on success.”
Gemini will analyze the files in the project and, after only a few seconds, propose a change to the user.routes.js file. You can review the change directly in the chat and accept it. Notice how in the new code, Gemini provides an object that includes the MongoDB-specific _id field. This shows that Gemini is aware that the project uses MongoDB and not another database.

If you’re curious about how the interactive chat works, check out the guide in the IDX documentation.
Conclusion
The MongoDB template for Project IDX is a great way to get started quickly with MongoDB without needing any local setup. It’s perfect if you have a locked-down corporate machine, dealing with restrictions on installing software, or are just looking for a quick way to prototype something.
With Project IDX, you get a customizable, cloud-based development environment, built on top of the familiar Code OSS project. On top of that, you get free AI code assistance with Gemini.
Once you’ve finished prototyping with the local database, you can always transition to a database, running outside of IDX, like MongoDB Atlas.




