mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
19 lines
456 B
TypeScript
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,
|
|
),
|
|
);
|
|
};
|