Skip to content

A login gate for websites

Only the people you invite get in.

PreviewLatch puts a password screen in front of a website, so you can share it with a client or your team without the rest of the internet seeing it. Despite the name, it is not only for previews:

  • Preview deployments
  • Staging sites
  • Client sites
  • Private tools

One line of middleware for Next.js. Open source, MIT licensed.

private

How it works

Set it up once. Take access back whenever you like.

  1. 1

    Add one line of middleware

    Install the previewlatch package, put your site key in PREVIEWLATCH_KEY and add this file. Every request now goes through the gate first.

    proxy.ts
    // proxy.ts (Next.js 16).  On Next.js 14 and 15 the same code goes in middleware.ts.import { previewlatch } from "previewlatch/next";export default previewlatch();
  2. 2

    Invite people

    Add the people who should see the site and give each one a password. PreviewLatch makes the password and shows it to you once, so you can send it however you like.

    • Password: reusable, for someone who will come back.
    • One-time password: works for exactly one sign in.
    • Expiring password: stops after an hour, a day, a week, a month, or on a date you pick.
  3. 3

    Revoke any time

    Remove a person, revoke one password, end one session, or sign everyone out. It reaches your site within your recheck interval: 60 seconds unless you change it.

    Sessions

    • Dana (client)Signed in
    • Sam (design)Signed in
    • Old reviewerRevoked

What gets covered

The whole site, not just the pages.

The gate runs in your site's own server before anything is sent. Without a valid session, a request gets a 401 and nothing from your site.

  • Pages, including ones that do not exist
  • API routes and route handlers
  • Static files and built JavaScript and CSS
  • Image optimisation URLs
  • Prefetch and data requests
  • robots.txt and sitemaps

Visitors and crawlers see a login screen and nothing else. Every logged-out response carries a noindex signal, so search engines leave it out.

The login screen does not show your site's name. No title, no address, no content. It says the site is private and asks for a password.

Sign in happens on your own domain. Your visitors' browsers never talk to PreviewLatch. Your server checks the password with us and signs its own cookie.

What a logged-out visitor sees. No site name, no address, no content.

The fine print, up front

What to expect, stated plainly.

How fast a revocation takes effect

Revoking a session, a password or a person, or signing everyone out, takes effect within your site's recheck interval: 60 seconds by default. You can set it per site from 15 seconds to 15 minutes. This holds as long as your site's server can reach PreviewLatch.

If PreviewLatch is down

People who are already signed in keep working. A session lasts until its own expiry or until it has gone 24 hours without a successful check, whichever comes first. You can change that grace period; set it to 0 to lock people out on the first failed check. New sign ins need PreviewLatch, so while it is down the login screen says sign in is unavailable.

A clear no is final

If PreviewLatch answers that a session is no longer valid, it ends at once. Only a missing answer is treated as an outage.

Uptime

There is no uptime guarantee. We will publish measured uptime instead of promising a number.

What it does not protect

A login gate in your server cannot reach everything. The main gaps:

  • A CDN in front of your site that caches by URL
  • Hosts that serve _next/static without running middleware
  • Paths you exclude by adding a matcher
  • Static exports, and assets or APIs on other domains
  • Deployments made before you added the middleware
  • Someone sharing their password or cookie
The full list, with what to do about each

How it is built

Open source middleware, hosted dashboard.

The middleware is yours to read

The gate is the previewlatch package on npm, MIT licensed, with no runtime dependencies. The dashboard where you manage people and passwords is hosted by us.

A database leak gives away no keys

We keep only a hash of part of your site key and a keyed hash of each password. The key that signs cookies never leaves your server. A copy of our database gives no working keys and no working passwords.

Frameworks

  • Next.jsAvailable
  • NuxtPlanned
  • SvelteKitPlanned
  • AstroPlanned
  • ExpressPlanned

Planned means not available yet.

Pricing

Free to start. One flat price later.

Now

A generous free tier

Lock your previews and client sites without paying while you get going.

Later

One flat price, unlimited sites

Not a fee per site. Lock as many sites as you run for the same price.

Pricing is not final. Nothing is billed today.

Lock your next preview.

Make an account, add a site, paste one file.