React Native & Expo

Technically this example does not necessitate it’s own page, but I wanted to list it here just to showcase it’s possible.

Standard data fetching

React Native does not introduce any specific native data fetching methods, they are equivalent to react’s client-side fetching patterns.

@tanstack/query

You can check out the official @hulla/api-query integration for more info.

Here’s a minimal example

import { api } from '@hulla/api'
import { query } from '@hulla/api-query'

const a = api()
export const usersAPI = a.router({
  name: 'users',
  routes: [a.procedure('getAllUsers', () => db.users.get())],
  adapters: { query }, // added the query adapter here
})

and then

import { useQuery } from '@tanstack/react-query'

export function ClientComponent() {
  const { data } = useQuery(usersAPI.query.call('getAllusers'))
  // ...
}

RSC & server actions

export function action() {
  'use server'
  return usersAPI.call('getAllUsers')
}

But this may be subject to change and is not yet ready for current use.