Xata Workers Beta

Xata Workers is our take on serverless functions. We're building a platform that makes it easy to write and deploy code to edge directly from your client-side code.

The Beta program of Xata Workers is closed. You can check out our Public Roadmap about planned features. If you have any questions please reach out to us via Discord or Support

import { useQuery } from '@tanstack/react-query';
import { xataWorker } from '~/xata';
 
const listProducts = xataWorker('listSomeProducts', async ({ xata }) => {
  return await xata.db.products.sort('popularity', 'desc').getMany();
});
 
export const Home = () => {
  const { data = [] } = useQuery(['products'], listProducts);
  return (
    <Grid>
      {data.map((product) => (
        <ProductCard key={product.id} product={product} />
      ))}
    </Grid>
  );
};