Skip to main content
React is a JavaScript library for building reactive user interfaces. Meteor provides seamless integration with React through the react-meteor-data package, allowing you to build modern, reactive applications.

Installation

Install React in your Meteor application:
For reactive data integration, add the react-meteor-data package:

Quick Start

Create a new React app with Meteor:
This creates a basic structure with React configured and ready to use.

Basic Setup

Client Entry Point

Render your React application in /client/main.jsx:

Root Component

Create your root component in /imports/ui/App.jsx:

Reactive Data with useTracker

The useTracker hook integrates React components with Meteor’s reactive data system.

Basic Usage

With Subscriptions

Modern Hooks API

useSubscribe

Convenient subscription management:

useFind

Optimized list rendering with controlled document references:
useFind requires a cursor, not .fetch(). It uses Cursor.observe to efficiently update only changed documents.

withTracker HOC

For class components or legacy code:

Suspense Support (Meteor 3.0+)

Use suspendable hooks with React Suspense:
Suspendable hooks require a unique key as the first argument to identify computations.

Routing with React Router

Meteor works seamlessly with React Router:

Integration Patterns

Use React components inside Blaze templates with react-template-helper:
In your Blaze template:
Define the component helper:

Best Practices

The useTracker hook is preferred over withTracker for function components. Hooks provide better composition and are easier to test.
Provide dependency arrays to useTracker to retain computations and prevent unnecessary re-runs:
For rendering large lists from collections, useFind provides significant performance benefits by controlling object references.
Wrap list items with React.memo() to prevent unnecessary re-renders:

Resources

React Tutorial

Step-by-step tutorial for building React apps with Meteor

React Packages

Source code and documentation for react-meteor-data

React Documentation

Official React documentation and guides

React Router

Client-side routing for React applications