meteor-react
Use when building or debugging React interfaces in Meteor 3: meteor create --react, createRoot, JSX or TSX entry points, Rspack React detection, Fast Refresh, react-meteor-data, useTracker, useSubscribe, useFind, withTracker, Suspense, and Tracker.withComputation. Triggers on isLoading being treated as a boolean, useFind receiving fetch(), stale closure inputs, duplicate tracker side effects, unstable Suspense keys, lost reactivity after await, state reset after refresh, or React tests leaking computations. Use this skill when the user asks about a React skeleton, React Compiler, React-specific rspack.config rules, reactive data hooks, or classic versus Suspense integration. Route general bundler configuration to meteor-modern-build-stack and Meteor 2 upgrades to migrate-to-meteor-3.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- meteor-react
- license
- MIT
- metadata
- { "area": "data", "kind": "knowledge", "author": "meteor", "bundle": [ "react" ], "meteor": ">=3.0", "tagline": "Build and debug Meteor 3 React interfaces (Rspack scaffold, reactive data hooks, Suspense, Fast Refresh, and testing).", "docs_synced_at": "2026-10-07" }
- description
- Use when building or debugging React interfaces in Meteor 3: meteor create --react, createRoot, JSX or TSX entry points, Rspack React detection, Fast Refresh, react-meteor-data, useTracker, useSubscribe, useFind, withTracker, Suspense, and Tracker.withComputation. Triggers on isLoading being treated as a boolean, useFind receiving fetch(), stale closure inputs, duplicate tracker side effects, unstable Suspense keys, lost reactivity after await, state reset after refresh, or React tests leaking computations. Use this skill when the user asks about a React skeleton, React Compiler, React-specific rspack.config rules, reactive data hooks, or classic versus Suspense integration. Route general bundler configuration to meteor-modern-build-stack and Meteor 2 upgrades to migrate-to-meteor-3.
02 资源文件 4
- 参考文档references/build-refresh-and-testing.md7.1 KB
- 参考文档references/eval-cases.md9.0 KB
- 参考文档references/react-meteor-data.md6.3 KB
- 参考文档references/suspense-and-async.md5.1 KB
03 SKILL.md 正文
React interfaces for Meteor 3
React owns rendering and local UI state; Meteor owns reactive data and the build handoff. Components consume authorized data and invoke methods. Publications and methods remain the server authority.
Decision flow
- For a new JavaScript app, run
meteor create --react <name>; React is also the default skeleton. For TypeScript and TSX, runmeteor create --typescript <name>. - Inspect
package.json,.meteor/packages,.meteor/versions, the client entry, andrspack.config.*. Skeletons andreact-meteor-dataversions can change independently of this skill. - Mount one React root from
Meteor.startupwithcreateRoot. - Pick one
react-meteor-datasurface for a component:- Classic hooks for explicit loading UI and synchronous Minimongo reads.
- Suspense hooks only when an upstream Suspense fallback and rejection boundary already own the pending and error states.
- Use
useSubscribefor readiness,useFindfor reactive lists with stable document references, anduseTrackerfor other Tracker values. - Keep React-specific Rspack rules here. Route aliases, loaders, code splitting, cache, output, or migration work to the build skills.
- Test UI behavior in a browser-backed client suite and always unmount the rendered root so Tracker computations and subscriptions can stop.
Current scaffold
meteor create --react my-app
cd my-app
meteor
Current Meteor 3.4+ scaffolds use Rspack and react-meteor-data. Inspect
.meteor/versions: Meteor 3 requires 3.0.0+, these examples target 4.0.1, and
references/react-meteor-data.md records feature floors.
import { Meteor } from "meteor/meteor";
import { createRoot } from "react-dom/client";
import { App } from "/imports/ui/App";
import "/imports/ui/styles.css";
Meteor.startup(() => {
const container = document.getElementById("react-target");
if (!container) throw new Error("Missing #react-target");
createRoot(container).render(<App />);
});
TypeScript uses client/main.tsx, a tsconfig.json, and usually
rspack.config.ts. Meteor discovers that TypeScript config directly.
Reactive data selection
| Need | API | Contract |
|---|---|---|
| Subscription readiness | Classic useSubscribe |
Returns an isLoading function. Call it. |
| Reactive list | Classic useFind |
Return a cursor, never fetch(). |
| User, count, single document, ReactiveVar | Classic useTracker |
Return the reactive value. Avoid arbitrary side effects. |
| Async value with Suspense | Suspense useTracker |
Supply a stable key and Promise-producing function. |
| SSR-capable collection query | Suspense useFind |
Pass the collection and the find argument tuple. |
| Existing class component | withTracker |
Keep it during focused maintenance; plan hooks separately. |
Classic list scaffold:
import { useFind, useSubscribe } from "meteor/react-meteor-data";
import { Tasks } from "/imports/api/tasks";
export function TaskList({ listId }) {
const isLoading = useSubscribe("tasks.byList", listId);
const tasks = useFind(
() => Tasks.find({ listId }, { sort: { createdAt: -1 } }),
[listId],
);
if (isLoading()) return <p>Loading...</p>;
if (tasks.length === 0) return <p>No tasks.</p>;
return <ul>{tasks.map((task) => <li key={task._id}>{task.title}</li>)}</ul>;
}
useFind owns cursor observation and updates only changed document references.
Use useTracker when a transformed aggregate is clearer. Read
references/react-meteor-data.md before tuning dependencies or skipUpdate.
Suspense and async reactivity
Suspense imports change signatures; they are not drop-in replacements:
import { Suspense } from "react";
import { useFind, useSubscribe } from "meteor/react-meteor-data/suspense";
import { Tasks } from "/imports/api/tasks";
function TaskList({ listId }) {
useSubscribe("tasks.byList", listId);
const tasks = useFind(Tasks, [
{ listId },
{ sort: { createdAt: -1 } },
], [listId]);
return <ul>{tasks.map((task) => <li key={task._id}>{task.title}</li>)}</ul>;
}
export function TaskScreen({ listId }) {
return (
<AppErrorBoundary>
<Suspense fallback={<p>Loading...</p>}>
<TaskList listId={listId} />
</Suspense>
</AppErrorBoundary>
);
}
Treat Suspense useSubscribe as a suspension-only call. In the currently
audited package, its declared return type and runtime value disagree, so do not
consume the return. Read references/suspense-and-async.md for stable keys,
rejections, SSR, and Tracker.withComputation after await.
Build and refresh ownership
Rspack detects React from the app's npm dependencies, enables JSX or TSX SWC parsing, and installs and injects React Refresh for client development. A normal React Rspack app does not add the refresh plugin manually.
Keep rspack.config.* minimal. The generated JavaScript skeleton demonstrates
an optional SVGR rule; the TypeScript skeleton demonstrates type checking.
Compose custom rules through defineConfig from @meteorjs/rspack without
replacing Meteor's SWC defaults.
For React Compiler, the Meteor 3.6 pairing supports SWC; older pairings can retain Babel. Read compiler setup for React-version targets and runtime requirements.
| Request | Owner |
|---|---|
| React detection, JSX or TSX, React Refresh boundary | This skill |
General rspack.config helpers, SWC, aliases, cache, chunks |
meteor-modern-build-stack |
| Convert an existing app or legacy build plugin to Rspack | migrate-to-rspack |
Meteor-bundler HMR or custom module.hot lifecycle |
Build skill, then this skill for React symptoms |
If edits reload the page or reset component state, first determine which
bundler compiled the module. In a Rspack client graph, inspect React Refresh
boundaries and avoid a second react-fast-refresh stack. In a Meteor-bundler
graph, verify hot-module-replacement and the bundled React Fast Refresh
integration. See references/build-refresh-and-testing.md.
Mutations and tests
Call Meteor.callAsync from event handlers, model pending and rejection in
React state, and leave validation and authorization inside the method. Do not
write sensitive collections directly from a component.
For tests, separate a presentational component that accepts data as props from the hook-owning container. Unit-test the former with the project's existing React test library. Test the latter in a browser client with controlled Minimongo or a real publication. Assert rendered behavior, not the number of reactive-function calls, because React can discard work and invoke initial render logic more than once.
Anti-patterns
- Treat classic
isLoadingas a boolean. It is a function and must be called. - Pass
Tasks.find().fetch()touseFind. Return the cursor. - Put a subscription inside a
useFindfactory. Subscribe separately. - Call React state setters, methods, analytics, or arbitrary effects inside a
useTrackerreactive function. - Force every classic component onto Suspense. Both surfaces remain useful.
- Reuse a generic Suspense key for unrelated mounted computations.
- Read a Tracker source only after
awaitwithout restoring the computation. - Add
@rspack/plugin-react-refreshto project config when Meteor already injected it. - Replace all Rspack SWC options to add one React transform. Extend them.
- Mock away all Meteor data behavior in a component integration test.
Authoritative resources
04 同仓库更多 Skills
migrate-to-rspack
Use when migrating an existing Meteor app to Rspack (Meteor 3.4+), or upgrading Rspack 1 to 2 on Meteor 3.6. Triggers on nested imports, mainModule entry points, server-only apps, replacing fourseven:scss / meteor/less / coffeescript / jorgenvatle:vite / zodern:melte with loaders, Svelte/TypeScript preprocessing or Lingui SWC plugin failures after upgrade, CommonJS default-import interop, module.exports in client graphs, Node built-ins in browser code, _build / build-assets / build-chunks, .meteorignore hiding handoff files, dynamic chunks under ROOT_URL, meteor.modules for CSS/HTML, resolve.symlinks or resolve.alias migration, automatic dependency updates and immutable CI/Docker builds. Use this skill when the user asks about migration compatibility or a build plugin's Rspack replacement. For new-app setup and rspack.config.js helpers, use meteor-modern-build-stack instead.
migrate-to-meteor-3
Use when migrating a Meteor 2.x application to Meteor 3.x. Triggers on callAsync, *Async Mongo, removed Fibers, implicit-global ReferenceError, lost Blaze reactivity, a publish function returning a Promise, a scheduler dropping a Promise, a read API receiving update modifiers, async allow/deny, an Iron Router controller not running, "Method stub took too long", Atmosphere resolution, Express 5 WebApp handlers, lost async context, rawCollection callbacks, TypeScript declaration failures during upgrades, useTracker, and useSubscribe. Use this skill when the user asks about upgrading Meteor, async caller propagation, iterators with await, or replacing and forking packages. Standalone declarations and type-checking belong to meteor-typescript.
meteor-typescript
Use when setting up or repairing Meteor application declarations, TypeScript configuration, JavaScript IntelliSense, or local and CI type-checking. Triggers on meteor types, meteor/* imports resolving to any, missing declarations, duplicate Meteor identifiers, zodern:types, @types/meteor, .meteor/types, tsconfig.json, jsconfig.json, and tsc --noEmit in a Meteor app. Use this skill when choosing or migrating declaration providers without changing the app's runtime or bundler. For a Meteor 2-to-3 runtime migration use migrate-to-meteor-3 first; for SWC/Rspack compilation use meteor-modern-build-stack or migrate-to-rspack. General TypeScript language questions and Atmosphere declaration publishing are outside this app scope.
meteor-testing
Use when setting up, designing, writing, or repairing tests and test harnesses in a Meteor 3 app. Triggers on meteortesting:mocha, --driver-package, TEST_WATCH, TEST_BROWSER_DRIVER, MOCHA_GREP, meteor.testModule, focused tests, .only, Meteor.server.method_handlers, Meteor.server.publish_handlers, DDP.connect, --full-app integration mode, sinon, async test signatures, Playwright/Cypress E2E. Use this skill when the user asks about test runners, asks about testing publications, or asks about Jest vs Mocha in Meteor. For a failing, hanging, or flaky test whose failing layer or root cause is unknown, use meteor-debugging before changing the test or app.
meteor-security
Use when auditing or hardening a Meteor 3 application. Triggers on missing check() on method arguments, missing this.userId guards on publications, browser-policy CSP, DDPRateLimiter rules, oauth-encryption via Accounts.config oauthSecretKey, audit-argument-checks, allow/deny legacy patterns, BrowserPolicy.content.disallowInlineScripts, BrowserPolicy.framing.disallow. Use this skill when the user asks about hardening, asks about a security review, or asks about CSP for a third-party script (Stripe, Google Maps, fonts).
meteor-mongo-minimongo
Use when authoring or debugging Mongo queries in Meteor 3. Triggers on Mongo.Collection, find/findOne, server async vs client Minimongo sync, oplog vs change streams, indexes, selectors, modifiers, projections. Use this skill when the user asks about Mongo on the server or asks about Minimongo on the client.