Publish Preview

Publish Preview is a copy-paste React component that stops npm publish shipped .env before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/publish-preview
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

Stopsnpm publish shipped .env

Was this component page useful?

How do I install Publish Preview?

pnpm dlx shadcn@latest add @bollard/publish-preview

The files land in your project. They're yours to edit.

How do I use Publish Preview in React?

publish-preview-usage.tsx
import { PublishPreview, type PublishFix } from "@/components/ui/publish-preview"

<PublishPreview
  pack={pack}
  pkg={pkg}
  published={["1.4.0", "1.4.1", "1.4.2"]}
  gitignore={"node_modules\n/dist\ncoverage\n"}
  hasNpmignore={false}
  onFix={onFix}
  onPublish={() => new Promise<void>((resolve) => setTimeout(() => (setLog(`+ ${PKG.name}@${state.version}`), resolve()), 900))}
/>

What input mistakes does Publish Preview catch?

  • .env files and keys in the tarball
  • Source maps, tests and repo config shipped by accident
  • Entry points missing from the build, with the reason (.gitignore fallback, files list, no build)
  • Version already published, with a next version
  • private: true, or no files allowlist

What props does Publish Preview accept?

PublishPreview props
PropTypeDefault
pack* (required)

Output of `npm pack --dry-run --json` (string or parsed).

string | PackResult | unknown—
pkg

The package.json (object or text) of the package being checked.

PackageJson | string—
packageName

With `--workspaces` output, which package to check. Defaults to the one named in `pkg`, else the first.

string—
onFix

Called with a change to make; the issue then waits for a fresh `pack` to confirm it.

(fix: PublishFix, issue: PackIssue) => void—
onPublish

Shows the publish button, enabled when nothing blocks. May return a Promise for a pending state.

() => void | Promise<void>—
maxFiles

Files listed before "Show more"; flagged files always come first.

number8
locale

Locale for sizes.

string—
messages

Any visible string.

Partial<PublishPreviewMessages>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Publish Preview accessible?

  • File list is a labelled section; the issue list is focusable
  • Fix buttons are real buttons; waiting state has text
  • Icons are aria-hidden

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Run npm pack checks in CI with a files allowlist and provenance before publishing.

  • Needs the pack output and package.json you pass; it doesn't run npm
  • A fix only counts after a fresh pack
  • Doesn't check the package's runtime behaviour

What expensive mistakes does Publish Preview stop?

npm publish shipped .env

Also known as

npm publish · npm pack · package.json · files field · .npmignore · tarball · library · semver

What dependencies does Publish Preview require?

Publish Preview facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePublish Preview
Registry identifier@bollard/publish-preview
Install commandnpx shadcn@latest add @bollard/publish-preview
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Publish Preview

What form validation mistake does Publish Preview catch?

Publish Preview prevents npm publish shipped .env. Previews what npm publish will ship from npm pack --dry-run and flags .env files, source maps, tests and missing build output before it goes out. Catches: .env files and keys in the tarball, Source maps, tests and repo config shipped by accident, Entry points missing from the build, with the reason (.gitignore fallback, files list, no build), Version already published, with a next version, private: true, or no files allowlist. Limitation: validate publish-preview schemas on backend.

How do I install publish-preview with shadcn?

Run `npx shadcn@latest add @bollard/publish-preview`. Sources added: registry/default/publish-preview/pack-review.ts, registry/default/publish-preview/publish-preview.tsx. Package requirements: lucide-react.

What props customize Publish Preview?

Publish Preview accepts `pack`, `pkg`, `packageName`, `onFix`, `onPublish`. Configures npm publish, npm pack, package.json behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of publish-preview?

Needs the pack output and package.json you pass; it doesn't run npm. A fix only counts after a fresh pack. Doesn't check the package's runtime behaviour Server requirement: Run npm pack checks in CI with a files allowlist and provenance before publishing.

How does Publish Preview meet accessibility guidelines?

File list is a labelled section; the issue list is focusable. Fix buttons are real buttons; waiting state has text. Icons are aria-hidden. Minimizes errors: npm published secrets, package missing dist.

Which components pair with Publish Preview?