Skip to content
← Templates

Minimal Access

A copy-paste React access screen for internal tools and quick gates — a single masked field, no frills. One file, zero dependencies.

Internal dashboardSimpletemplateminimalv1.1.0

Best used for A quick, no-frills gate for an internal tool where tone doesn't matter.

For when a segmented code doesn't fit the tone of what you're gating — one field, one button, done. No footer text unless you pass your own.

// Usage

Minimal setup

<MinimalAccessTemplate expectedHash={process.env.NEXT_PUBLIC_KNOCK_HASH}>
  <YourApp />
</MinimalAccessTemplate>
FIG.01Demo code: 4242
Installation

Add this template to your project

Recommended

npx shadcn@latest add @knock-codes/minimal-access-template

Also installs

  • Knock Codes Core
  • Knock Codes Types
  • useKnockCodes
  • cx (classname helper)
  • PIN Input

These install together as one atomic unit — even a presentational or read-only piece needs the full verification stack (hook, types, core) behind it to actually run.

Files created (10)

  • components/knock-codes/core/hash.ts
  • components/knock-codes/core/verify.ts
  • components/knock-codes/core/session.ts
  • components/knock-codes/core/storage.ts
  • components/knock-codes/react/types.ts
  • components/knock-codes/react/useKnockCodes.ts
  • components/knock-codes/react/KnockCodesContext.tsx
  • components/knock-codes/react/cx.ts
  • components/knock-codes/react/PinInput.tsx
  • components/knock-codes/react/MinimalAccessTemplate.tsx
Other ways

GitHub shorthand

npx shadcn@latest add trivedi-vatsal/knock-codes/minimal-access-template

Copy the files by hand

  1. Open the Code tab in the preview above.
  2. Create each path listed below in your project and paste its contents in.
  3. Do the same for anything listed under “Also installs”, if present.

Installing via an AI agent?

Drop AGENTS.md into your project root — it instructs any coding agent to hash the code locally, write only the hash, and confirm the plaintext never touched a file. Thin pointer files exist for tools that read a different filename.

// Props

API reference

PropTypeDefaultDescription
expectedHashstringSHA-256 hex hash to verify against, for local mode.
verifyVerifyFnCustom async verification function, for server mode.
validateSession(session: KnockCodesSession) => boolean | Promise<boolean>Called when a session is read from storage. Return false or throw to reject it (server-mode token check).
children *ReactNodeRendered once unlocked.
logoReactNodeRendered above the heading — your own logo/wordmark. Omitted entirely if not passed.
supportHrefstringRenders "Contact support" as a link to this URL.
onContactSupport() => voidRenders "Contact support" as a button instead of a link — e.g. to open a chat widget.
labelsMinimalAccessTemplateLabelsOverrides heading, description, input label, support label, footer text, and every KnockCodesLabels string.
fullPagebooleantrueSet false to embed this somewhere other than a real page root (a demo, a docs preview) — drops the full-viewport (100dvh) sizing.
theme"light" | "dark"Forces light or dark presentation on its own, independent of any ancestor ".dark" class. Omit to follow the nearest ".dark" ancestor if one happens to exist.
remember"session"Persists the unlocked session across reloads within the same tab via sessionStorage. Not a security boundary — see the security model.
classNamestringExtra classes on the full-page backdrop.

Exactly one of expectedHash or verify is required.

Notes

Accessibility

The code field has its own label and an accessible show/hide toggle (aria-label switches between "Show code"/"Hide code"). Errors and the submitting state announce through a shared aria-live="polite" region, same contract as every other block.

Customization

Everything is one file — background, card, heading, description, field, button, support link, and footer are all inline, not composed from Gate Wrapper/PIN Input. Pass `logo` for your own wordmark and `labels` to override every string. For segmented code entry instead of a single field, use Knock Codes Template instead.

Security & Verification

Need a hash? Use the hash generator on Getting Started — computed locally, never sent anywhere.

The honest version

Knock Codes stops casual visitors, search engines, and forwarded links. Local mode does not stop anyone who opens DevTools — the hash ships in your client bundle by design. Server mode (swap one prop) hides the hash from the client; children you already bundled are still in the JavaScript, and a forged session works unless you wire validateSession. A velvet rope, with an optional real lock. Never marketed as more than that.

// Compose with

Blocks this template is built from

Drop down to these directly once you need more control than the single-file template gives you.