Adding helpers usually involves:
-
Adding code (and corresponding .test.ts file) to:
- ./server/ if it helps write server-side code (imported in convex/)
- ./react/ for client-side code. In the future beyond react/ there can be other framework-specific client-side helpers.
- ./ if it's truly generic - can be imported client or server-side
-
Adding the file to the root package.json or in the following places:
- exports in the npm library package.json
using
node generate-exports.mjs
. - scripts: Update the
dev:helpers
script if it isn't being included by the existing globs, and thebuild
command if it's not included in thecp
command.
- exports in the npm library package.json
using
-
package README.md blurb on how to use it, and a link in the TOC.
-
root README.md link in the TOC.
-
Adding an example of usage in the root of this repo.
- convex/fooExample.ts for server-side code
- src/components/FooExample.tsx for client-side code, added in App.tsx
-
A Stack post on it - what problem it solves, a blurb on how to use it. Update this README with the link when it's live.
- Include a block comment at the top of the file about how to use it.
- Include jsdoc comments on exported functions etc. about how to use them.
- Include motivation for why someone would use this helper, for browsing.
- Avoid introducing too many files. Things are more discoverable within a file.
Run commands from this folder (root of repo).
NOTE: make sure you aren't running npm run dev
anywhere when you're
publishing to avoid races with re-generating files while publishing.
In general you can run ./publish.sh
to go through the publish workflow.
It will prompt you for a new version. If you've already adjusted the version,
you can just hit enter.
When it shows the publish preview, ensure the files all look like they're there. After you confirm to publish, it will publish to npm, make a git commit, tag the commit with the version, and push the current branch & that tag.
For alpha releases, you can run ./publish.sh alpha
.
Or run this beforehand to bump the version:
npm version prerelease --preid alpha && git add package*
.
Only use alpha, otherwise npm won't tag it correctly and it might suggest it as
convex-helpers@latest
instead of just as convex-helpers@alpha
.