Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/appwrite/sdk-for-svelte
Appwrite SDK for Svelte 🧡 ⚠️ Warning - this SDK was designed to support Appwrite 0.9 and is not compatible with the latest Appwrite versions. We are planing to refactor it as part of the SDK Generator for better support and maintenance.
https://github.com/appwrite/sdk-for-svelte
appwrite hacktoberfest svelte sveltejs
Last synced: about 10 hours ago
JSON representation
Appwrite SDK for Svelte 🧡 ⚠️ Warning - this SDK was designed to support Appwrite 0.9 and is not compatible with the latest Appwrite versions. We are planing to refactor it as part of the SDK Generator for better support and maintenance.
- Host: GitHub
- URL: https://github.com/appwrite/sdk-for-svelte
- Owner: appwrite
- License: bsd-3-clause
- Created: 2020-09-25T04:10:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-31T00:56:20.000Z (6 months ago)
- Last Synced: 2025-01-14T11:12:50.064Z (8 days ago)
- Topics: appwrite, hacktoberfest, svelte, sveltejs
- Language: Svelte
- Homepage: https://appwrite.io
- Size: 191 KB
- Stars: 74
- Watchers: 20
- Forks: 13
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**⚠️ Warning - this SDK was designed to support Appwrite 0.9 and is not compatible with the latest Appwrite versions. We are planing to refactor it as part of the [SDK Generator](https://github.com/appwrite/sdk-generator) for better support and maintenance.**
# svelte-appwrite (Beta)
Easy to use [Appwrite](https://appwrite.io/) components for Svelte. Install it:
```bash
npm install svelte-appwrite
# or
yarn svelte-appwrite
```# Table of contents
- [Usage](#usage)
- [Initialize](#initialize)
- [Create user](#create-user)
- [Login via Email](#login-via-email)
- [Login via OAuth2](#login-via-oauth2)
- [Get user](#get-user)
- [Get Collection](#get-collection)
- [Get Document](#get-document)
- [API](#api)
- [Account](#account)
- [``](#user-)
- [``](#create-)
- [``](#delete-)
- [``](#preferences-)
- [``](#recoverpassword-)
- [``](#update-)
- [Auth](#auth)
- [``](#authemail-)
- [``](#authoauth2-)
- [Avatars](#avatars)
- [``](#browser-)
- [``](#creditcard-)
- [``](#favicon-)
- [``](#flag-)
- [``](#image-)
- [``](#qr-)
- [Database](#database)
- [``](#collection-)
- [``](#document-)
- [Storage](#storage)
- [``](#storage-)
- [``](#filelist-)
- [``](#file-)
- [Locale](#locale)
- [``](#continents-)
- [``](#countries-)
- [``](#currencies-)
- [``](#locale-)
- [``](#phonecodes-)# Usage
> You need a running instance of Appwrite to use this library. Go to https://appwrite.io/docs/installation for more instructions.
**Psuedo Example**
Handle multiple levels of async relational data (and their loading & fallback states) entirely from the Svelte HTML.
```svelte
Hello {user.name}!
You have {documents.length} documents.
{#each documents as document}
Title: {document.title}
Text: {document.text}
...
```## Initialize
Must be initialised and wrap every `svelte-appwrite` component.
```svelte
import { Appwrite } from "svelte-appwrite";
const config = {
endpoint: "http://localhost/v1",
project: "5f4938898667e",
locale: "de",
};...
```
### Properties
| Name | Description |
| --- | --- |
| `endpoint` | Your Appwrite endpoint |
| `project` | Your project ID |
| `locale` | _Optional_ The users locale |## Create user
Registers a new account.
```svelte
import { Create } from "svelte-appwrite";
let email = "";
let password = "";
let name = "";const success = e => {
//success callback
// `e` contains the user object
};const failure = e => {
//failure callback
}
Register```
### Directives
**let:actions** `object`
Object with function.
#### Arguments
| Name | Description |
| --- | --- |
| `create(email, password, name)` | Registers a new user. |### Events
**on:success**
Triggers on successful register.
#### Arguments
| Name | Description |
| --- | --- |
| `response` | Response |**on:failure**
Triggers on failed register.
#### Arguments
| Name | Description |
| --- | --- |
| `response` | Response |## Login via Email
Login via email and password.
```svelte
import { AuthEmail } from "svelte-appwrite";
let email = "";
let password = "";const success = e => {
//success callback
// `e` contains the user object
};const failure = e => {
//failure callback
}
Login```
### Directives
**let:authorize** `function`
Initiates login.
#### Arguments
| Name | Description |
| --- | --- |
| `email` | E-Mail |
| `password` | Password |### Events
**on:success**
Triggers on successful login.
#### Arguments
| Name | Description |
| --- | --- |
| `email` | E-Mail |**on:failure**
Triggers on failed login.
#### Arguments
| Name | Description |
| --- | --- |
| `error` | Error object. |## Login via OAuth2
Login via an OAuth2 provider.
```svelte
import { AuthOAuth2 } from "svelte-appwrite";
Login Google
```
### Properties
| Name | Description |
| --- | --- |
| `provider` | OAuth2 provider |
| `success` | Success url |
| `failure` | Failure url |### Directives
**let:authorize** `function`
## Get user
Requests current user to check if logged in.
```svelte
import { User } from "svelte-appwrite";
Hello {user.name}!
{user.email}
You are not logged in!
```
### Directives
**let:user** `object`
Get currently logged in user data.
## Get Collection
Get a list of all the documents from a collection.
```svelte
import { Collection } from "svelte-appwrite";
You have {documents.length} documents.
```
### Properties
| Name | Description |
| --- | --- |
| `collection` | Collection unique ID. |
| _additional_ | same as [here](https://appwrite.io/docs/client/database#listDocuments) |### Directives
**let:documents** `array`
Array of documents.
**let:actions** `object`
Object with function.
#### Arguments
| Name | Description |
| --- | --- |
| `reload()` | Re-fetch collection. |
| `create(data, read, write)` | Create a new Document in the collection. `read`/`write` is optional and current user by default. |## Get Document
Get a document. If you pass the `document` property with data from , there wont be any data requested.
```svelte
import { Document } from "svelte-appwrite";
Title: {document.title}
Text: {document.text}```
### Properties
| Name | Description |
| --- | --- |
| `id` | Document unique ID |
| `collection` | Collection unique ID |
| or |
| `document` | Document passed from `` |### Directives
**let:document** `object`
A JSON object with the document data.
**let:actions** `object`
Object with function.
#### Arguments
| Name | Description |
| --- | --- |
| `update(data)` | Update the document. |
| `remove()` | Deletes the document. |
| `reload()` | Re-fetch document. |### Events
**on:change**
Triggers on update or remove login.
# API
## Account
The Account components allow you to manage a user account.### ``
#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |
| `logout()` | Logout current session. |
| `logoutAll()` | Logout from all session. |
| `logoutFrom(session)` | Logout from specific session. |- **let:user**
- **let:error**#### Events
- **on:success** On user fetch success.
- **on:failure** On user fetch failure.
- **on:successLogout** On `logout` success.
- **on:failureLogout** On `logout` failure.
- **on:successLogoutFrom** On `logoutFrom` success.
- **on:failureLogoutFrom** On `logoutFrom` failure.
- **on:successLogoutAll** On `logoutAll` success.
- **on:failureLogoutAll** On `logoutAll` failure.### ``
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `create(email, password, name)` | Creates a user. |#### Events
- **on:success** On `create` success.
- **on:failure** On `create` failure.### ``
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `delete()` | Deletes currently logged in user. |#### Events
- **on:success** On `delete` success.
- **on:failure** On `delete` failure.### ``
#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reloads preferences. |
| `update(prefs)` | Update preferences. |#### Events
- **on:success** On init and `reload` success.
- **on:failure** On init and `reload` failure.
- **on:successUpdate** On `update` success.
- **on:failureUpdate** On `update` failure.### ``
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `recover(email, url)` | Recover password. |
| `complete(user, secret, password, passwordAgain)` | Complete password recovery. |#### Events
- **on:successRecover** On init and `reload` success.
- **on:failureRecover** On init and `reload` failure.
- **on:successComplete** On `update` success.
- **on:failureComplete** On `update` failure.### ``
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `name(name)` | Update name. |
| `email(email, password)` | Update email. |
| `password(password, oldPassword)` | Update password. |#### Events
- **on:successName** On `name` success.
- **on:failureName** On `name` failure.
- **on:successEmail** On `email` success.
- **on:failureEmail** On `email` failure.
- **on:successPassword** On `password` success.
- **on:failurePassword** On `password` failure.### ``
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `create(url)` | Create Verification. |
| `complete(user, secret)` | Complete Verification. |#### Events
- **on:successCreate** On `create` success.
- **on:failureCreate** On `create` failure.
- **on:successComplete** On `complete` success.
- **on:failureComplete** On `complete` failure.## Auth
The Auth components allow you to authenticate a user account.### ``
#### Slots
- **loading**
- **success**
- **error**#### Directives
- **let:authorize(email, password)**
- **let:user**
- **let:error**#### Events
- **on:success** On `authorize` success.
- **on:failure** On `authorize` failure.### ``
#### Properties
| Name | Description |
| --- | --- |
| `provider` | OAuth2 provider |
| `success` | Success url |
| `failure` | Failure url |
#### Directives**let:authorize()**
## Avatars
The Avatar components aim to help you complete everyday tasks related to your app image, icons, and avatars.### ``
#### Arguments
- code
- width
- height
- quality#### Directives
- **let:src** Image link
### ``
#### Arguments
- code
- width
- height
- quality#### Directives
- **let:src** Image link
### ``
#### Arguments
- url
#### Directives
- **let:src** Image link
### ``
#### Arguments
- code
- width
- height
- quality#### Directives
- **let:src** Image link
### ``
#### Arguments
- url
- width
- height#### Directives
- **let:src** Image link
### ``
#### Arguments
- text
- size
- margin
- download#### Directives
- **let:src** Image link
## Database
The Database components allow you to create structured collections of documents, query and filter lists of documents, and manage an advanced set of read and write access permissions.### ``
#### Arguments
- id
- filters
- offset
- limit
- orderField
- orderType
- orderCast
- search
- first
- last#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |
| `create(data, read, write)` | Creates a Document. |- **let:documents**
- **let:error**### ``
#### Arguments
- id
- collection
- document#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |
| `update(data)` | Updates a Document. |
| `remove()` | Removes a Document. |- **let:document**
- **let:error**## Storage
The Storage components allow you to manage your project files. You can upload, view, download, and query all your project files.### ``
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `create(file, read, write)` | Uploads a file. |- **let:files**
### ``
#### Arguments
- search
- limit
- offset
- orderType#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |- **let:files**
- **let:error**### ``
#### Arguments
- file
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `download()` | Downloads file. |
| `view(as)` | Get file for View. |
| `preview(width, height, quality, background, output)` | Get file for preview. |
| `update(read, write)` | Updates a file. |
| `delete()` | Deletes a file. |## Locale
The Locale components allow you to customize your app based on your users' location.### ``
#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |- **let:continents**
#### Slots
- **loading**
- **error**### ``
#### Arguments
- eu
#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |- **let:countries**
### ``
#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |- **let:currencies**
### ``
#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |- **let:code**
### ``
#### Slots
- **loading**
- **error**#### Directives
**let:actions**
| Name | Description |
| --- | --- |
| `reload()` | Reload. |- **let:codes**