# User context Cherry tells your app who opened it and how to look: the person's public profile, their language and theme, the platform and how far system UI reaches into your view. Everything arrives before your first screen, and it updates while the app is open. ## Language and theme The host appends the language and the color scheme to your URL, so they are known on the first frame and on your server: ``` https://app.example.com/?cherry_lang=ru&cherry_theme=dark&... ``` The SDK merges that with what the host sends after the handshake and with the launch token's `locale` claim. In React, `useCherryDisplayContext()` is never empty: ```tsx import { useEffect, type ReactNode } from 'react'; import { applyCherryContextToDocument, useCherryDisplayContext } from '@cherrydotfun/miniapp-sdk/react'; import { i18n } from './i18n'; // your i18n library export function CherryLook({ children }: { children: ReactNode }) { const { locale, colorScheme, safeArea } = useCherryDisplayContext(); useEffect(() => { applyCherryContextToDocument({ locale, colorScheme }); // , data-cherry-theme, color-scheme if (locale) void i18n.changeLanguage(locale); }, [locale, colorScheme]); return
{children}
; } ``` | Field | Values | | --- | --- | | `locale` | `en`, `ru`, `de`, `fr`, `es`, `id`, `vi`, `zh`, `ja`, `ko` | | `colorScheme` | `dark` or `light` | | `brand` | The Cherry skin the person uses, for example `cherry` | | `platform` | `ios`, `android` or `web` | | `safeArea` | `{ top, right, bottom, left }` in CSS pixels | When the person switches language or theme, or rotates the phone, the host sends the new context and the hooks re-render. Without React, `cherry.onContextChange(cb)` does the same. ## The person's profile `useCherryUser()` (or `cherry.context.user`) is the person's public Cherry profile, the same things anyone sees on their Cherry page: | Field | | | --- | --- | | `cherryId`, `handle`, `displayName`, `avatarUrl`, `bio` | Who they are | | `level` | Cherry level and points | | `pet` | Their pet: name, species, stage, picture | | `socials` | Linked accounts they show: X, Telegram and others, with `verified` | | `wallets` | Their public wallets, with domains | | `badges` | Cherry badges | | `social` | Follower and following counts | | `trading` | Public PnL and volume, when they show it | Wallets the person hid, contact details, keys and anything else that is not on their public page never reach your app. ```tsx const user = useCherryUser(); return user ? : null; ``` ## Followers and following Lists are read from the Cherry API with the launch token, page by page: ```ts const me = await cherry.users.me(); const page = await cherry.users.followers(me.cherryId, { limit: 100 }); // { items, nextCursor } const more = await cherry.users.following(me.cherryId, { cursor: page.nextCursor ?? undefined }); const { following, followedBy } = await cherry.users.relationship(otherCherryId); const friend = await cherry.users.get(otherCherryId); // any person's public profile ``` Use it for friend leaderboards, "invite who you follow", or showing who among a person's follows already plays. The API only returns public data, so it accepts the launch token for 24 hours after the token expires. Past that, open the app again for a fresh token. ## On your backend The profile in the browser is for display: the browser can be tampered with. Your backend verifies the launch token ([Authentication](https://portal.cherry.fun/docs/mini-apps/authentication.md)) and reads the same API itself, once, when it exchanges the token for your session: ```bash curl -H "Authorization: Bearer $LAUNCH_TOKEN" https://chat.cherry.fun/api/miniapp/me curl -H "Authorization: Bearer $LAUNCH_TOKEN" "https://chat.cherry.fun/api/miniapp/users/$CHERRY_ID/followers?limit=100" ```