Skip to content

Authentication

To protect your apps behind authentication, you can make use of a variety of authentication middlewares.

If your app is using hono, you have a variety of options to choose from:

But smallweb also provides a few authentication middlewares that you can use over any fetch handler.

Generally, you can use these middlewares by wrapping your app fetch handler with them.

For example, if you want to protect your app behind email using https://lastlogin.net:

ts
// ~/smallweb/excalidraw/main.ts
import { Excalidraw } from "jsr:@pomdtr/excalidraw";
import { lastlogin } from "jsr:@pomdtr/lastlogin";

const excalidraw = new Excalidraw();
excalidraw.fetch = lastlogin(excalidraw.fetch);

export default excalidraw;
sh
# ~/smallweb/excalidraw/.env

LASTLOGIN_SECRET_KEY=your-secret-key # a randomly generated string
LASTLOGIN_EMAIL=[email protected]