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.
We have this feature in beta and would love to have you try it out. If you have a use-case in mind or excited about this new feature, please reach out via Support and we will get in touch with you!
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>
);
};