Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Design and build reusable Convex components with isolated tables, backend functions, and app-facing wrappers.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/packaged-components.md
1# Packaged Convex Components23Read this file when the user wants a reusable npm package or a component shared4across multiple apps.56## When to Choose This78- The user wants to publish the component9- The user wants a stable reusable package boundary10- The component will be shared across multiple apps or teams1112## Default Approach1314- Prefer starting from `npx create-convex@latest --component` when possible15- Keep the official authoring docs as the source of truth for package layout and16exports17- Validate the bundled package through an example app, not just the source files1819## Build Flow2021When building a packaged component, make sure the bundled output exists before22the example app tries to consume it.2324Recommended order:25261. `npx convex codegen --component-dir ./path/to/component`272. Run the package build command283. Run `npx convex dev --typecheck-components` in the example app2930Do not assume normal app codegen is enough for packaged component workflows.3132## Package Exports3334If publishing to npm, make sure the package exposes the entry points apps need:3536- package root for client helpers, types, or classes37- `./convex.config.js` for installing the component38- `./_generated/component.js` for the app-facing `ComponentApi` type39- `./test` for testing helpers when applicable4041## Testing4243- Use `convex-test` for component logic44- Register the component schema and modules with the test instance45- Test app-side wrapper code from an example app that installs the package46- Export a small helper from `./test` if consumers need easy test registration4748## Checklist4950- [ ] Packaging is actually required51- [ ] Build order avoids bundle and codegen races52- [ ] Package exports include install and typing entry points53- [ ] Example app exercises the packaged component54- [ ] Core behavior is covered by tests55