Docs

Getting Started for Web

Appwrite is a development platform that provides a powerful API and management console to get your next project up and running quickly.

Create your first project now and start building on Appwrite Cloud.

Add Your Web Platform

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. Only web apps hosted on domains specified in a web platform will be able to make requests to your Appwrite instance, preventing unwanted access from malicious actors.

Web platforms allow wildcard hostnames through a * character. The wildcard character can be applied anywhere in a hostname, both *.example.com and prod.*.example.com are valid examples. Avoid using wildcards unless necessary to keep your Appwrite project secure.

Get Appwrite Web SDK

NPM

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

npm install appwrite

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

import { Client, Account, ID } 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:

<script src="https://cdn.jsdelivr.net/npm/appwrite@11.0.0"></script>
<script>
    const { Client, Account, ID } = Appwrite;
    // Your code below...
</script>

Init your SDK

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

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('[PROJECT_ID]');               // Your project ID

Make Your First Request

After your SDK configuration is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would use is found in the SDK documentation or in the API References section.

const account = new Account(client);

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

Listen to Changes

To listen to changes in realtime from Appwrite, subscribe to a variety of channels and receive updates within milliseconds. Full documentation for Realtime is found here.

// Subscribe to files channel
client.subscribe('files', response => {
    if(response.events.includes('buckets.*.files.*.create')) {
        // Log when a new file is uploaded
        console.log(response.payload);
    }
});

Full Example

import { Client, Account, ID } from "appwrite";

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('[PROJECT_ID]');               // Your project ID

const account = new Account(client);

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

// Subscribe to files channel
client.subscribe('files', response => {
    if(response.events.includes('buckets.*.files.*.create')) {
        // Log when a new file is uploaded
        console.log(response.payload);
    }
});

Demos

Below is a list of some demos to help you get started with Appwrite for Web using your favorite tools and framework of choice.

Demo GitHub Repository
Todo App with React JS appwrite/todo-with-react Live Example
Todo App with Vue JS appwrite/todo-with-vue Live Example
Todo App with Angular appwrite/todo-with-angular Live Example
Todo App with Svelte appwrite/todo-with-svelte Live Example

Next Steps

Appwrite has many services and tools to help improve your app and speed up your development. The best way to learn how you can take advantage of them is to explore the different API references docs.