Full-stack, runnable applications demonstrating MongoDB integration with modern JavaScript frameworks. These apps serve as the complete, tested source code for MongoDB framework tutorials.
A restaurant browsing application built with TanStack Start, MongoDB, and TanStack Query.
Tutorial: MongoDB with TanStack Start
Features:
- Server-side data fetching with MongoDB
- TanStack Query for client-side caching
- Full-stack TypeScript
- Comprehensive test suite (17 tests)
Quick Start:
cd frameworks/javascript/tanstack/app
npm install
cp .env.example .env
# Add your MongoDB connection string to .env
npm run devVisit http://localhost:3000 to see the app!
Each example demonstrates:
- MongoDB Connection - Connecting to MongoDB Atlas or local instance
- CRUD Operations - Creating, reading, updating, and deleting data
- Query Patterns - Filtering, sorting, and pagination
- Best Practices - Error handling, connection management, type safety
- Testing - Unit and integration tests for database operations
Each framework example follows this pattern:
javascript/{framework-name}/
├── app/ # Complete working application
│ ├── src/ # Source code
│ ├── package.json # App dependencies
│ └── .env.example # Environment template
├── tests/ # Test suite (unit + integration)
└── testedSnippets/ # Auto-generated code snippets for docs
All examples include comprehensive test suites. Tests run from the app/ directory:
cd frameworks/javascript/tanstack/app
# Run all tests (unit + integration, requires MongoDB)
npm run test:all
# Run only unit tests (no MongoDB required, default)
npm test
# Run only integration tests (requires MongoDB)
npm run test:integrationRequirements for integration tests:
- MongoDB instance (local or Atlas)
sample_restaurantsdatabase loaded (see tutorial for information on loading sample data into your MongoDB instance)- Valid
MONGODB_URIin.envfile
You may notice special comments in the code:
// :snippet-start: connect
const client = new MongoClient(uri)
// :snippet-end:These are Bluehawk annotations used to extract code snippets for documentation. They:
- Are standard TypeScript/JavaScript comments
- Don't affect code execution or compilation
- Can be safely ignored when learning from the code
- Ensure tutorial snippets stay in sync with working code
To generate documentation snippets from the source code:
cd frameworks/javascript/tanstack
npm install # Install Bluehawk and Prettier
npm run snip # Extract and format snippetsSnippets are written to testedSnippets/ with this naming pattern:
{filename}.snippet.{tag-name}.{ext}
Example: db.snippet.db-connection.ts
javascript/{framework-name}/
├── app/ # Source code (with Bluehawk annotations)
├── testedSnippets/ # Generated snippets (committed to repo)
├── package.json # Bluehawk + Prettier dependencies
├── snip.config.json # Snippet extraction config
└── .prettierrc # Code formatting rules
-
Add Bluehawk annotations to source code:
// :snippet-start: my-snippet // Your code here // :snippet-end:
-
Run extraction:
npm run snip
-
Verify output in
testedSnippets/
Learn more: Bluehawk Documentation
When adding or updating framework examples:
- Ensure the app runs independently and matches the tutorial
- Add comprehensive tests
- Add Bluehawk annotations to code sections used in tutorials
- Extract snippets and verify formatting
- Update this README with the new framework