Open Source Backend Server - AppWrite 🔥
Tags: appwrite, webdev, backend, server
Published: 2021-10-24 06:03:39


### Contents
1. [What is Appwrite?](#what-is-appwrite)
2. [Amazing Features](#amazing-features)
3. [Why Appwrite is better?](#why-appwrite-is-better)
4. [Installation](#installation)
5. [Hands On](#lets-try-it-out)
6. [Bonus](#bonus )🔥

---

## **💡 What is Appwrite?**

[Appwrite](https://appwrite.io/) is an open-source backend server for web and mobile applications. It is similar to Firebase, AWS Amplify, and Supabase in terms of features and APIs, including Authentication (User management), Database Management, Storage, and Cloud Functions.
It is a self-hosted solution that provides developers with a set of easy-to-use and integrate REST APIs to manage their core backend needs.

![Home Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q2o26mk4wwj2nv6otu4f.png)

[Back to Contents](#contents)

---

## **✨ Amazing Features!**

It can run on any operating system and the Console User Interface provides you with a great variety of services you can use with your project!

1. **Database** -Store, query and manage access control to your app documents

2. **Storage** - Upload, download and preview your app and users files and media

3. **Users** - Authenticate, confirm and manage your users using multiple signin methods

4. **GEO & Localization** - Detect your users location, locale and fetch GEO related data

5. **Functions** - Run your backend code in a secure and isolated environment to customize your app

6. **Console** - Track your backend API usage and manage your project resources from a modern UI

..... and others including **privacy**, **security** and many more.

[Back to Contents](#contents)

---

### **🤔 Why Appwrite is better?**

- **No Cost**
Appwrite is open-source, so we can expect everything for free here. Others options by companies like Microsoft, Amazon etc. can get expensive as you scale your product up. Appwrite has an upper edge here.

- **Usage Statistics**
Using the usage statistics provided by AppWrite, you can easily get to know which projects -
    - take up the most space
    - use more CPU time,  You can even see 
    - the bandwidth usage on each project separately
    ..... and many more stats.

- **API support**
Due to the amount of APIs that Appwrite provides to a user, building projects is much easier with having to do difficult task of bundling API servers together.

- **Task Manager**
Using Appwrite, you can schedule an automatic function execution using cron syntax. This function can do anything from sending newsletter emails to buying you a pizza. No limitations at all.

- **Community Support**
AppWrite has a great community support that is ready to help you all the time. If you have any doubt or query, you can have a chat in their [discord server](https://appwrite.io/discord), and you will get your query resolved faster than any other forums.

[Back to Contents](#contents)

---

### 📩 Installation

The easiest way to start running your Appwrite server is by running our **Docker** installer tool from your terminal. 
Before running the installation command, make sure you have [Docker CLI](https://www.docker.com/products/docker-desktop) installed on your host machine.

**For Unix**

```sh
docker run -it --rm \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
    --entrypoint="install" \
    appwrite/appwrite:0.11.0
```

**For Windows**

```sh
docker run -it --rm ^
    --volume //var/run/docker.sock:/var/run/docker.sock ^
    --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
    --entrypoint="install" ^
    appwrite/appwrite:0.11.0
```

**Note :**

- Hyper-V and Containers Windows features must be enabled to run Appwrite on Windows with Docker. 
- If you don't have these features available, you can install [Docker Toolbox](https://docs.docker.com/toolbox/toolbox_install_windows/) that uses Virtualbox to run Appwrite on a Virtual Machine.

[Back to Contents](#contents)

---

### 💥 Lets Try it Out

**Appwrite** can be used for Web, Apple, Flutter, Android etc. Here we will try to understand how to use it for Web.

Appwrite is a development platform providing you easy yet powerful API and management console to get your next project up and running quickly.

We will learn how ca you start using Appwrite products and build your next project. Before starting, make sure you have followed the Appwrite [installation](#installation), and you have an Appwrite server instance up and running on your host machine or server.

#### Step 1 : Create Your First Appwrite Project
Go to your new Appwrite console and once inside click the
'Create Project' button on your console homepage. Choose a name for your project and click create to get started.

![Home Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plzm143vz4nib23lmb2h.png) 

#### Step 2 : Add Your Web Platform
For you to init your SDK and interact with Appwrite services you need to add a web platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before and click the 'Add Platform' button.

From the options, choose to add a web platform and add your client app hostname. By adding your hostname to your project platform you are allowing cross-domain communication between your project and the Appwrite API.

#### Step 3 : Get Appwrite Web SDK

**NPM**
Use NPM (node package manager) from your command line to add Appwrite SDK to your project.

```sh
npm install appwrite
```

If you're using a bundler (like Browserify or webpack), you can import the Appwrite module when you need it:

```js
import { Appwrite } from "appwrite";
```

**CDN**
To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/appwrite@4.0.4">
</script>
```

**Init your SDK**
Initialize your SDK code with your project ID which can be found in your project settings page.

```js
// Init your Web SDK
const appwrite = new Appwrite();

appwrite
    .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
    .setProject('455x34dfkj') // Your project ID
;

```

#### Step 4 : Make Your First Request
Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.

```js
// Register User
appwrite
    .account.create('me@example.com', 'password', 'Jane Doe')
        .then(response => {
            console.log(response);
        }, error => {
            console.log(error);
        });
```

#### Step 5 : Listen to Changes
If you want to listen to changes in realtime from Appwrite, you can subscribe to a variety of channels and receive updates within milliseconds. Full documentation for Realtime can be found here.

```js
// Subscribe to files channel
appwrite.subscribe('files', response => {
    if(response.event === 'storage.files.create') {
        // Log when a new file is uploaded
        console.log(response.payload);
    }
});
```

#### Lets put everything together

```js
// Init your Web SDK
const appwrite = new Appwrite();

appwrite
    .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
    .setProject('455x34dfkj') // Your project ID

// Register User
appwrite
    .account.create('me@example.com', 'password', 'Jane Doe')
        .then(response => {
            console.log(response);
        }, error => {
            console.log(error);
        });

// Subscribe to files channel
appwrite.subscribe('files', response => {
    if(response.event === 'storage.files.create') {
        // Log when a new file is uploaded
        console.log(response.payload);
    }
});
```

[Back to Contents](#contents)

---

### Bonus 🔥

- **Resources**

| Appwrite | 🔗 |
| :------------- | :----------: |
| Github Repo | [Visit Repo](https://github.com/appwrite/appwrite) |
| Documentation | [Visit Docs](https://appwrite.io/docs) |
| Discord | [Join Sever](https://appwrite.io/discord) |
| 30 Days of Appwrite| [Lets Start](https://30days.appwrite.io/) |

- **Demos**

| Demo | 🔗 | 🔗 |
| :------------- | :----------: | :-----------: |
| Todo App with React JS | [Visit Repo](https://github.com/appwrite/todo-with-react) | [See Live](https://appwrite-todo-with-react.vercel.app/) |
| Todo App with Vue JS | [Visit Repo](https://github.com/appwrite/todo-with-vue) | [See Live](https://appwrite-todo-with-vue.vercel.app/) |
| Todo App with Angular | [Visit Repo](https://github.com/appwrite/todo-with-angular) | [See Live](https://appwrite-todo-with-angular.vercel.app/) |
| Todo App with Svelte | [Visit Repo](https://github.com/appwrite/todo-with-svelte) | [See Live](https://appwrite-todo-with-svelte.vercel.app/) |


{% link https://dev.to/appwrite/announcing-appwrite-0-9-the-open-source-firebase-alternative-53ho %}

{% link https://dev.to/daryllukas/authentication-exploring-appwrite-io-with-react-series-1iec %}

{% link  https://dev.to/appwrite/magic-url-authentication-with-flutter-appwrite-349g %}

---

*If you got to learn something new and useful show some love by giving this post a ❤️*

If you find it useful for you, **save this post** and share it with your programming buddies 😃

Have you tried Appwrite? Share your experience in the comment section! 💬