Skip to main content

Directory Structure

Meteor uses a convention-based file structure that determines where code runs and how it’s loaded.

Standard Layout

A typical Meteor project follows this organization:

Load Order Rules

Meteor loads files in a specific order based on their location:

1. Special Directories

Files in client/ run only in the browser. Meteor automatically excludes this code from the server bundle.
client/main.js
Files in server/ run only on the server (Node.js). This is where you put sensitive logic, API keys, and database operations.
server/main.js
Files in imports/ are not loaded automatically. You must explicitly import them. This enables code splitting and lazy loading.
imports/api/tasks.js
Files in public/ are served as static assets. They’re accessible at the root URL.
Files in private/ are accessible only to server code via the Assets API.
Files matching *.test.js, *.tests.js, or inside tests/ are excluded from production builds.
tasks.test.js

2. Load Priority

Within each directory, files load in this order:
  1. Files in subdirectories load before files in parent directories
  2. Files are sorted alphabetically by name
  3. main.* files load last
  4. Files in lib/ directories load first
Don’t rely on load order. Use explicit imports instead. Load order is a legacy feature maintained for backwards compatibility.

File Architecture Patterns

Use the imports/ directory with explicit imports:

Split by Feature

Organize code by feature rather than by type:

The .meteor Directory

The .meteor/ directory contains Meteor-specific configuration:

packages

Lists Meteor packages used by your app:

versions

Locks exact package versions (like package-lock.json for npm):

release

Specifies the Meteor version:
Commit .meteor/packages and .meteor/release to version control, but you can ignore .meteor/versions if using npm packages exclusively.

Build Output Structure

When you build a Meteor app, it generates a “star” archive with this structure:

Star Archive Layout

star.json

Describes the build output:

program.json

Each program has a program.json describing its resources: Web Program:
Server Program:

Best Practices

Put all application code in imports/ and explicitly import it. This gives you:
  • Explicit dependency graph
  • Better code splitting
  • Easier testing
  • No reliance on load order
Keep client/main.js and server/main.js minimal - just imports:
client/main.js
server/main.js
Organize by feature, not by file type:✅ Good:
❌ Avoid:
Code outside client/ and server/ runs on both sides. Be careful with:
  • API keys (use server-only)
  • Node.js modules (check Meteor.isServer)
  • Browser APIs (check Meteor.isClient)

Repository Structure

The Meteor source code itself follows this structure:

Learn More

Explore how Meteor’s package system works and how packages are structured