2024-06-08 01:09:15 +02:00
|
|
|
import type { LysandClient } from "@lysand-org/client";
|
2024-05-17 08:25:59 +02:00
|
|
|
import { StorageSerializers } from "@vueuse/core";
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-06-08 01:09:15 +02:00
|
|
|
// Return type of LysandClient.getInstance
|
|
|
|
|
export type Instance = Awaited<ReturnType<LysandClient["getInstance"]>>["data"];
|
2024-04-27 03:28:12 +02:00
|
|
|
|
2024-05-17 08:25:59 +02:00
|
|
|
export const useInstance = () => {
|
|
|
|
|
if (process.server) {
|
|
|
|
|
return ref(null);
|
2024-04-22 09:38:51 +02:00
|
|
|
}
|
|
|
|
|
|
2024-06-08 01:09:15 +02:00
|
|
|
return useLocalStorage<Instance | null>("lysand:instance", null, {
|
2024-05-17 08:25:59 +02:00
|
|
|
serializer: StorageSerializers.object,
|
|
|
|
|
});
|
2024-04-22 09:38:51 +02:00
|
|
|
};
|