Overview
Meteor Methods are the framework’s remote procedure call (RPC) system. They provide a secure way to send data from clients to the server, perform operations, and return results. Methods integrate tightly with Meteor’s data system to enable Optimistic UI.Think of Methods as POST requests to your server, but with automatic client-side simulation, latency compensation, and built-in security features.
What is a Method?
A Method is:- An API endpoint that can be called from client or server
- Defined once in code shared between client and server
- Automatically simulated on the client for instant UI updates
- Re-run on the server for validation and persistence
Defining Methods
Basic Method Definition
Using jam:method Package
For a more structured approach, use thejam:method package:
Calling Methods
From the Client
Using Promises
From the Server
Method Context (this)
Inside a Method,this provides:
Optimistic UI
Methods run twice:- Client simulation - Immediate UI update
- Server execution - Validation and persistence