Skip to content
← Templates

Branded Access

A copy-paste React password screen for client previews and private betas. One file, zero dependencies, local or server verification.

Client previewStandardtemplatebrandedsplit-screenv1.1.0

Best used for A private beta or soft-launch landing page where the access screen is also the first impression.

// Usage

Minimal setup

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

Add this template to your project

Recommended

npx shadcn@latest add @knock-codes/branded-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/BrandedAccessTemplate.tsx
Other ways

GitHub shorthand

npx shadcn@latest add trivedi-vatsal/knock-codes/branded-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 on the brand panel (and, on mobile, above the form) — your own logo/wordmark.
taglineReactNodeShort line under the logo on the brand panel. Hidden along with the rest of that panel below the lg breakpoint.
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.
labelsBrandedAccessTemplateLabelsOverrides 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 outer grid.

Exactly one of expectedHash or verify is required.

Notes

Accessibility

The code field has its own label and an accessible show/hide toggle. The brand panel is decorative and collapses out of the DOM's visual flow on small screens rather than stacking above the form, so mobile visitors reach the field without scrolling. Errors and the submitting state announce through a shared aria-live="polite" region, same contract as every other block.

Customization

Everything is one file — brand panel, form panel, heading, description, field, button, support link, and footer are all inline. Pass `logo` and `tagline` for the brand panel, and `labels` to override every string. The brand panel is hidden below the `lg` breakpoint so mobile visitors see only the form.

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.