name: appwrite-react-vite description: Appwrite integration for React projects created with Vite. Use when implementing Appwrite Auth, TablesDB access, session flows, and secure frontend-to-backend boundaries in React SPA setups.
Appwrite React Vite
Use this skill for React SPA projects using Vite and Appwrite.
Verified Baseline
- React quick start uses
npm create vite@latest my-app -- --template react. - Install SDK with
npm install appwrite. - Configure endpoint as
https://<REGION>.cloud.appwrite.io/v1and set project ID.
Setup Workflow
- Create Appwrite project and register Web platform for local/prod origins.
- Scaffold React app with Vite.
- Add a dedicated Appwrite client module for browser-safe SDK usage.
- Implement signup, login, logout, and current-user bootstrapping.
- Add server-side path for privileged actions instead of API key use in browser.
Environment Rules
- Keep endpoint and project ID in Vite env variables.
- Use only
VITE_prefixed variables in client runtime. - Keep secrets and API keys outside Vite client env.
Auth Pattern
- Use
Account.create,createEmailPasswordSession,get,deleteSession. - On app bootstrap, attempt
account.get()and hydrate auth state. - Handle session expiration and unauthorized responses centrally.
Data Pattern
- Use client-side reads only for user-permitted resources.
- Use backend or Appwrite Functions for admin operations.
- Prefer TablesDB APIs for new database development.
Security Guardrails
- Never ship API keys to browser bundles.
- Avoid
Role.any()on mutable resources. - Enforce permission checks server-side for critical writes.
- Reduce overfetching with
Query.select.
Common Pitfalls
- CORS errors from missing domain in Appwrite platforms list.
- Broken auth state when startup user-check is skipped.
- Permission confusion when table grants exist but row grants do not.
- Large payloads from list queries without select and pagination.