Skip to content

Question: how to implement Telegram CloudStorage with persist storage #2775

Answered by Xyzjesus
Xyzjesus asked this question in Ideas
Discussion options

You must be logged in to vote

think i got your point, i've done some changes:

import { create } from "zustand";
import { persist, createJSONStorage } from "zustand/middleware";
import { initCloudStorage } from "@telegram-apps/sdk";

const cloudStorage = initCloudStorage();

const cloudStorageWrapper = {
  getItem: async (name: string): Promise<string | null> => {
    try {
      const value = await cloudStorage.get(name);
      return value ? value : null;
    } catch (error) {
      console.error(`Error getting item ${name} from CloudStorage:`, error);
      return null;
    }
  },
  setItem: async (name: string, value: string): Promise<void> => {
    try {
      await cloudStorage.set(name, value);
    } catch (error) 

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Xyzjesus
Comment options

@dbritto-dev
Comment options

@Xyzjesus
Comment options

@Xyzjesus
Comment options

Answer selected by Xyzjesus
@dbritto-dev
Comment options

@Xyzjesus
Comment options

@dbritto-dev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants