The SvelteKit Basic Auth is a hook that adds password protection to an app. It checks for a valid authentication token and prompts the user to login using the browser’s built-in authentication mechanism. The hook retrieves a list of username-password pairs from an environment variable and allows the authorized username to be accessed from the page data.
To install the SvelteKit Basic Auth hook, follow these steps:
src/hooks.server.ts.env.example and add a list of username-password pairs in the format USERNAME1:PASSWORD1, USERNAME2:PASSWORD2, ...The SvelteKit Basic Auth hook provides a simple and efficient way to add password protection to your SvelteKit app. By checking for a valid token and prompting the user to login, it ensures only authorized users can access the protected areas of your app. The hook retrieves username-password pairs from an environment variable, allowing you to easily manage and update the authorized users.