Async read atom suspend tự nhiên trong khi fetch — component dùng useAtomValue(userAtom) cần được bọc <Suspense>.
Đây là tích hợp React Suspense tự nhiên nhất trong các thư viện state.
ts
const userAtom = atom(async (get) => {
const id = get(userIdAtom)
return await fetchUser(id)
})loadable(userAtom)từjotai/utilstrả về{ state: 'loading'|'hasData'|'hasError', data, error }— dùng khi muốn tự kiểm soát loading UI thay vì Suspense.atomWithQuerytừjotai-tanstack-querynhúng TanStack Query vào atom:atomWithQuery(() => ({ queryKey: ['posts'], queryFn: fetchPosts })).
Lưu ý: async atom re-fetch mỗi khi atom phụ thuộc thay đổi và không có stale-time sẵn như React Query — cần chiến lược cache phức tạp thì dùng atomWithQuery.