Implementation
Using Both
Implement both native authentication and OAuth into your application
- To implement native authentication and OAuth, you can use SvelteKit’s Sequence helper function.
- In your existing
hooks.server.ts
file, add the following:
import { sequence } from '@sveltejs/kit/hooks';
/*
NOTE: CANNOT HAVE 2 HANDLE FUNCTIONS!
export const handle = SvaultNative(redirectPath);
export const handle = SvaultOauth({ providers });
*/
// Rename functions to their corresponding type of authentication
export const native = SvaultNative(redirectPath);
export const oauth = SvaultOauth({ providers });
// Use sveltekit sequence method to run both hooks in sequence
export const handle = sequence(oauth, native);