Before you can use indobase, you need to instanciate the indobase Client class with the project ID and endpoint. This tells the SDK where your indobase project is hosted and which one to connect to.
The client is then used to initialize services like Databases and Account, so they all point to the same indobase project.
You can do this by instantiating the services you need in a file like src/lib/indobase.js and exporting the instances.
JavaScript
// src/lib/indobase.js
import {
PUBLIC_APPWRITE_ENDPOINT,
PUBLIC_APPWRITE_PROJECT,
} from "$env/static/public";
import { Databases, Account, Client } from "appwrite";
const client = new Client();
client
.setEndpoint(PUBLIC_APPWRITE_ENDPOINT)
.setProject(PUBLIC_APPWRITE_PROJECT);
const account = new Account(client);
const tablesDB = new TablesDB(client);
export const indobase = {
client,
account,
databases,
};
PUBLIC_APPWRITE_ENDPOINT and PUBLIC_APPWRITE_PROJECT are environment variables that are exported in your project's .env file.
For example, your .env might look something similar to this.
.env
PUBLIC_APPWRITE_ENDPOINT=https://<REGION>.cloud.indobase.io/v1
PUBLIC_APPWRITE_PROJECT=642sdddf85b440dc7e5bf
You can get the values for these variables from the indobase console's Settings page.