gpt-4o-2024-11-20· OpenAI
WildChat-4.8M (AI2)
get user theme is dark or light using @twa-dev/sdk typescript
- User
get user theme is dark or light using @twa-dev/sdk typescript
- Assistant
To get the user's theme (dark or light) using
@twa-dev/sdk, you can use thetheme. Thethememodule in the@twa-dev/sdkprovides theme-related information, including the current theme used in Telegram Web Apps.Here is a brief guide on how to do this in TypeScript:
Install the SDK
Ensure that you've installed the
@twa-dev/sdkpackage:bashnpm install @twa-dev/sdkRetrieve the User's Theme
You can use the
theme.currentThemeproperty to get the current theme (either"dark"or"light") and subscribe to its changes if needed.typescript