react-meteor-data package, allowing you to build modern, reactive applications.
Installation
Install React in your Meteor application:react-meteor-data package:
Quick Start
Create a new React app with Meteor: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
TheuseTracker 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
- React in Blaze
- Blaze in React
Use React components inside Blaze templates with In your Blaze template:Define the component helper:
react-template-helper:Best Practices
Use hooks over HOCs
Use hooks over HOCs
The
useTracker hook is preferred over withTracker for function components. Hooks provide better composition and are easier to test.Optimize with dependency arrays
Optimize with dependency arrays
Provide dependency arrays to
useTracker to retain computations and prevent unnecessary re-runs:Use useFind for large lists
Use useFind for large lists
For rendering large lists from collections,
useFind provides significant performance benefits by controlling object references.Memoize list items
Memoize list items
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