0.1.5 • Published 1 year ago

appwrite-hooks v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Appwrite React hooks

Realtime stores synced with Appwrite collections and user.

Installation

yarn add https://github.com/ScalaeStudio/appwrite-hooks

Usage

import { useUser, useCollection } from 'appwrite-hooks'
import { Client, Databases, Account } from 'appwrite'

// Ideally do that in a separate module
const appwriteClient = new Client()
const appwriteDatabase = new Databases(appwriteClient)
const appwriteAccount = new Account(appwriteClient)
client
    .setEndpoint('http://your-appwrite-instance/v1')
    .setProject('your-project')

function YourComponent() {
    const { account, loaded, error } = useUser(appwriteClient, appwriteAccount)
    const { documents, loaded, error } = useCollection(
        appwriteClient,
        appwriteDatabase,
        "database-id",
        "collection-id",
    )
    const { document, loaded, error } = useDocument(
        appwriteClient,
        appwriteDatabase,
        "database-id",
        "collection-id",
        "document-id",
    );

    return (<>...</>)
}
0.1.5

1 year ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago