Skip to content
// Copy-paste. Zero runtime dependencies.

Knock, knock.
Private previews, secured.

A password screen you paste into your project. No backend, no npm install, no platform upgrade. Set an env var and ship.

For freelancers, agencies, and teams shipping previews to clients

01 / How it works

Three steps, no infrastructure.

Copy a file, generate a hash, wrap your app. Ship it.

Copy the file01

One template, zero runtime dependencies.

Paste a single file into your project, or install it with the shadcn CLI. Nothing to configure at the platform layer.

Generate a hash02

Turn your code into a SHA-256 hash.

Type an access code into the generator below and copy the hash it produces — computed locally, never sent anywhere.

Wrap and deploy03

Wrap your app, set one env var.

Wrap the page in the gate, set the hash as an environment variable, and deploy. That's the whole install.

Hash your code

Generate a hash

Type or generate a code to get its hash. Only the hash gets pasted into your project, never the plaintext.

Runs entirely in your browser. Nothing is sent anywhere.

03 / Local vs. server

Hides the hash, not the children.

Server mode keeps the hash off the client. Anything you already bundled is still in the JavaScript.

Local modeServer mode
SetupPaste a template, drop in a hashOne prop swap + a small endpoint
Hash visibilityShips in the client bundleStays on your server
Bundled childrenStill in the JavaScriptStill in the JavaScript unless you fetch after unlock
Stored sessionClient-writable unless validateSessionSame — validateSession to reject a forged token
Rate limitingNot possibleYes, per identifier
StopsCasual visitors, crawlers, forwarded linksReading the hash — not bundled children on their own
04 / FAQ

Common questions

Is this real authentication?

No. There's no user identity, no accounts, no permissions — everyone who has the code gets the same access. It's a shared secret, not authentication. See the security model for exactly what it does and doesn't protect against.

Why not use my host's built-in password protection?

If your host already offers one and it fits, use that instead. It's one less thing to maintain. Knock Codes is for when that option doesn't exist: a host with no built-in gate, a framework you don't want to configure at the platform layer, or a screen where the gate needs to live in your own app code instead.

Does it work with Next.js App Router and RSC?

Yes. Every template is a small client component that a Server Component can render as a child — that's exactly how this homepage's own live demo works. Streaming, RSC payloads, and the App Router's caching are unaffected; the gate only touches what's rendered inside it.

Can search engines bypass it?

Search engines that only read server-rendered HTML won't see what's behind the gate — local mode never renders the protected content until a matching code is entered, so there's nothing indexable in the initial markup. That's not a guarantee of invisibility, though — see the next question. Put noindex on any staging or preview deploy regardless; don't rely on the gate alone to keep it out of search results.

In local mode, does the protected content still ship in the bundle?

Usually, yes. Whatever you pass as children is still part of your React tree and your JavaScript bundle — the template just doesn't render it to the DOM until the state flips to unlocked. If what's behind the gate is genuinely sensitive, don't rely on this alone: fetch it only after unlock, or move it behind server mode.

How do I rotate a code?

Generate a hash for the new code and replace the old one — the env var in local mode, or your server's secret in server mode — then redeploy. Existing unlocked sessions keep working until they expire or are cleared, but nobody can unlock with the old code again.

Can I use multiple codes?

Not out of the box in local mode — expectedHash compares against exactly one hash. For more than one valid code, use server mode: your verify function can check the submitted code's hash against a list or lookup table on your server, where the comparison logic is entirely up to you.

05 / Ship it

Ready to lock something down?

Pick a template, copy the file, wire a hash. Ship it in minutes.