Contributing
Monorepo layout, the playground, tests, these docs and releasing.
Repository layout
next-toolbar/
├── packages/next-toolbar/ the npm package (@angelitolm/next-toolbar)
│ ├── src/ component, core logic, styles, icons
│ ├── logo.svg
│ └── README.md the README published to npm
├── playground/ Next app with one route per scenario
├── docs/ this documentation site (Next + MDX, en/es)
├── pnpm-workspace.yaml
└── LICENSEPrerequisites
- Node.js 22.18+ (tests run TypeScript directly with Node's type stripping)
- pnpm 11
pnpm installScripts
| Command | What it does |
|---|---|
pnpm dev | Builds the package in watch mode and starts the playground (port 3100) and the docs (port 3200) |
pnpm build | Builds the package with tsup |
pnpm test | Runs the package's unit tests |
pnpm --filter @angelitolm/next-toolbar typecheck | Type-checks the package |
pnpm --filter docs test | Checks that both languages have the same messages and pages |
The playground
Every route exercises one scenario:
| Route | Scenario |
|---|---|
/ | Static page |
/dynamic | Uses headers(): Dynamic |
/isr | revalidate = 60 and an external fetch (fails offline: a server error) |
/cache | force-cache, revalidate: 30 and no-store fetches to a local API |
/blog/[slug] | Dynamic segment without generateStaticParams: Static? |
/boom | Throws while rendering: 500 and a server error (kept visible by app/error.tsx) |
/nope | 404 |
/client-error | Button that throws in the browser |
/api/time | Route handler used by /cache |
Its next.config.ts enables requestInsights and moves Next's indicator to the top right.
Code conventions
- Logic worth testing goes in
src/core.tsas pure functions, with a test incore.test.ts. The component files stay thin. - No new runtime dependencies: the package only has peer dependencies.
- Anything that reads Next internals must degrade to
?if the data is missing. - Match the surrounding style: TypeScript, single quotes, no semicolons.
The docs site
The docs are a Next.js app with MDX, next-intl (English and Spanish) and Tailwind.
| Path | Purpose |
|---|---|
content/<locale>/<slug>.mdx | Page content (no # title; it comes from the messages) |
messages/<locale>.json | UI strings, section names, page titles and descriptions |
lib/pages.ts | Page order, sections, icons and the MDX import table |
mdx-components.tsx | <Callout> and locale-aware links |
To add a page:
- Add the slug to a section in
lib/pages.ts, with an icon and its two imports. - Create
content/en/<slug>.mdxandcontent/es/<slug>.mdx. - Add
pages.<slug>.titleanddescriptionto both message files. - Run
pnpm --filter docs test.
Link between pages with ./slug (and ./ for the home page); the links keep the reader's language. Use <Callout type="note | tip | warning"> for asides.
Testing a release locally
Before publishing, try the exact package npm would get in a real app:
pnpm test && pnpm run packThis writes .tarballs/angelitolm-next-toolbar-<version>.tgz (git-ignored). Install that file in the app, restart next dev and check it:
pnpm add -D C:/dev/next-toolbar/.tarballs/angelitolm-next-toolbar-0.2.0.tgzDon't use pnpm link for this: the package would resolve its own dev copy of React and the app would load two, which breaks hooks. When you're done, go back to the registry version with pnpm add -D @angelitolm/next-toolbar@latest.
Releasing
- Bump
versioninpackages/next-toolbar/package.json. pnpm build && pnpm test, then test the tarball as above.- Commit, then tag and push:
git tag v<version> && git push origin v<version>. The Publish workflow checks the tag matchesversion, runs the checks and publishes to npm with provenance (trusted publishing, no token).
License
MIT, © 2023–2026 Angel Labrada Massó. Icons: Iconsax via iconsax-react (MIT).