Database Backend
The starter template includes Appwrite backend integration that allows you to store any value in the database. Currently used for storing push tokens, Appwrite provides a database, authentication, and cloud functions platform that you can extend for your app’s needs.
For setting up Appwrite, refer to the Appwrite Configuration page.
AppwriteProvider
The AppwriteProvider initializes the Appwrite client and exposes functions through the useAppwrite() hook:
Available Functions
isConfigured
Boolean indicating if Appwrite is properly configured.
addExpoPushToken(token)
Stores an Expo push notification token in the database.
import { useAppwrite } from "@/app/providers/AppwriteProvider";
const { addExpoPushToken } = useAppwrite();
await addExpoPushToken("ExponentPushToken[xxxxx]");storeValue(collection, data)
Generic function to store data in any collection.
const { storeValue, isConfigured } = useAppwrite();
if (isConfigured) {
await storeValue("your_collection", {
key: "value"
});
}useFetch Hook
Custom hook for API requests with automatic loading and error handling:
import useFetch from "@/hooks/useFetch";
const { data, isLoading, error, refetch } = useFetch(
"https://api.example.com/data"
);
if (isLoading) return <Text>Loading...</Text>;
if (error) return <Text>Error: {error.message}</Text>;
return <Text>{JSON.stringify(data)}</Text>;