Drop in authentication including redirects for SvelteKit apps.
MIT License
Drop in authentication including route protection and redirects for SvelteKit apps.
Adding authentication to front end is one of the most time consuming tasks. Building apps in Svelte is great but there is no standard way to implement authentication. There are multiple libraries that allow us to add authentication for multiple providers. However, switching from one to another is not easy. The UI components for all the providers also need to meet the provider guidelines for the final app to be approved.
This is an attempt to make adding authentication to SvelteKit apps as simple as possible. This framework has been designed for Svelte.
Get started quickly using degit. Select the library you want to use and run degit to get a sample app.
degit jerrythomas/sentry/examples/supabase my-app
Take a look at the following files/folders in the sample to understand how it works.
This library uses WindiCSS and the components will not render properly if the required classes are not included in the final bundle. Ensure that the sentry library is included in the extract configuration of windi.config.js
extract: {
include: [
'./src/**/*.{html,js,svelte,ts}',
'node_modules/@jerrythomas/sentry/src/**/*.{html,js,svelte,ts,css}}'
]
}
Routes are configurable as shown in the example config/routes.js
file. Sentry assumes that all routes are private by default. Public routes need to be listed so that they can be accessed without logging in.
This library consists of the following components.
Cookie parsing and serializing is required to support server side auth guard. The original npm library jshttp/cookie ran into problems on SvelteKit v1.0.0-next.218. The code has been converted from CJS to ESM.
MIT © Jerry Thomas