webapp package provides Meteor’s built-in HTTP server, serving your application over HTTP and managing client-server communication.
Installation
The
webapp package is included by default in all Meteor applications.Overview
WebApp provides:- HTTP Server - Built on Express 5.x
- Static Asset Serving - Automatic bundling and serving of client files
- Middleware Support - Express middleware integration
- WebSocket Support - For DDP connections via SockJS
- Hot Code Push - Automatic client updates
- Modern/Legacy Bundles - Differential serving based on browser capabilities
Package Information
- Version: 2.1.0
- Summary: Serves a Meteor app over HTTP
- Dependencies:
express@5.1.0,compression@1.7.4,cookie-parser@1.4.6 - Exports:
WebApp(server),WebAppInternals(server)
Basic Usage
Server-Side Exports
Client-Side
Express Integration
WebApp is built on Express 5.x. You can add middleware to the Connect/Express server:Adding Middleware
Custom Routes
Using Express Middleware
Raw Connect Handlers
HTTP Handlers
Request Handler
Response Manipulation
Static File Serving
Custom Static Files
Download Handler
Client Serving
Modify HTML Before Serving
Runtime Config
Suppressing Default Behavior
Suppress Connect Handlers
Server Listening
Get Server Instance
Custom Port and Host
Compression
WebApp includes automatic response compression:Security Headers
Cookie Parsing
WebApp includes cookie-parser:Request Logging
Error Handling
Client Hash
WebApp provides version information for cache busting:Hot Code Push
Detect Reload
Customize Reload Behavior
Modern vs Legacy Bundles
WebApp serves different JavaScript bundles based on browser capabilities:WebSocket Configuration
Complete Example: REST API
Performance Tips
Related Packages
ddp
DDP protocol over WebSocket
autoupdate
Hot code push system
boilerplate-generator
HTML generation for client
browser-policy
Security headers and CSP