Skip to main content

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 the jam: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:
  1. Client simulation - Immediate UI update
  2. Server execution - Validation and persistence

Error Handling

Throwing Errors

Handling Errors

Validation

Using check()

Using SimpleSchema

Security Best Practices

Never Trust this.userId from Client

One Method Per Action

Rate Limiting

Advanced Patterns

Unblocking Methods

Simulation Control

Method Chaining

Testing Methods