Skip to content

Latest commit

 

History

History
147 lines (106 loc) · 3.24 KB

File metadata and controls

147 lines (106 loc) · 3.24 KB

Appwrite

Open-source backend platform with authentication, databases, storage, and serverless functions.

GitHub Education Access

Claim your free access at GitHub Education Pack - look for Appwrite.

Dashboard

Features

  • Authentication: Email, OAuth, phone, magic URL, anonymous
  • Databases: Document-based with relationships
  • Storage: File uploads with compression and encryption
  • Functions: Serverless in 13+ languages
  • Messaging: Email, SMS, push notifications
  • Realtime: WebSocket subscriptions

Quick Setup

JavaScript/Node.js

npm install appwrite
import { Client, Account, Databases } from 'appwrite';

const client = new Client()
  .setEndpoint(process.env.APPWRITE_ENDPOINT)
  .setProject(process.env.APPWRITE_PROJECT_ID);

const account = new Account(client);
const databases = new Databases(client);

React

import { Client, Account } from 'appwrite';

const client = new Client()
  .setEndpoint('https://cloud.appwrite.io/v1')
  .setProject('your-project-id');

// Auth
const account = new Account(client);
await account.createEmailPasswordSession(email, password);

Python

pip install appwrite
from appwrite.client import Client
from appwrite.services.databases import Databases

client = Client()
client.set_endpoint(os.environ.get('APPWRITE_ENDPOINT'))
client.set_project(os.environ.get('APPWRITE_PROJECT_ID'))
client.set_key(os.environ.get('APPWRITE_API_KEY'))

databases = Databases(client)

Appwrite CLI

npm install -g appwrite-cli

# Login
appwrite login

# Initialize project
appwrite init project

# Deploy functions
appwrite deploy function

Configuration

Copy from templates/appwrite/:

  • appwrite.json - CLI project config
  • .env.example - Environment variables

Environment Variables

APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_PROJECT_ID=your_project_id
# Get from: https://cloud.appwrite.io → Project Settings

APPWRITE_API_KEY=your_api_key
# Get from: Console → Settings → API Keys

Database Example

// Create document
const document = await databases.createDocument(
  'database-id',
  'collection-id',
  ID.unique(),
  { name: 'John', email: 'john@example.com' }
);

// Query documents
const documents = await databases.listDocuments(
  'database-id',
  'collection-id',
  [Query.equal('name', 'John')]
);

Functions Example

// functions/hello/src/main.js
export default async ({ req, res, log }) => {
  log('Hello from function!');
  return res.json({ message: 'Hello World' });
};

Best Practices

  1. Use API keys server-side only: Never expose in client code
  2. Set up permissions: Configure collection and bucket permissions
  3. Use realtime sparingly: Subscribe only to needed channels
  4. Implement auth flows: Use OAuth for easier user onboarding
  5. Structure collections: Plan database schema before building

Resources