svelte-clerk
Version:
Svelte Clerk is the easiest way to add authentication and user management to your Svelte and SvelteKit applications. Add sign up, sign in, and profile management to your application in minutes.
13 lines (12 loc) • 427 B
JavaScript
import { getContext, setContext } from 'svelte';
const _contextKey = '$$_clerk';
export const useClerkContext = () => {
const client = getContext(_contextKey);
if (!client) {
throw new Error('No Clerk data was found in Svelte context. Did you forget to wrap your component with ClerkProvider?');
}
return client;
};
export const setClerkContext = (context) => {
setContext(_contextKey, context);
};