frontend/composables/Megalodon.ts
2024-06-07 13:09:15 -10:00

19 lines
456 B
TypeScript

import { LysandClient, type Token } from "@lysand-org/client";
export const useClient = (
tokenData?: MaybeRef<Token | null>,
disableOnServer = false,
): Ref<LysandClient | null> => {
if (disableOnServer && process.server) {
return ref(null);
}
return computed(
() =>
new LysandClient(
new URL(useBaseUrl().value),
toValue(tokenData)?.access_token,
),
);
};