Migrating from @vaiftech/client
@vaiftech/client is the SDK’s retired package name. @vaifstudio/client replaces it. If your app uses @vaif/client, the step is smaller: install @vaifstudio/client and change the imports, because the API is the same.
1. Swap the dependency
Section titled “1. Swap the dependency”npm uninstall @vaiftech/clientnpm install @vaifstudio/client2. Rewrite the imports
Section titled “2. Rewrite the imports”# macOSgrep -rl '@vaiftech/client' src | xargs sed -i '' 's|@vaiftech/client|@vaifstudio/client|g'# Linuxgrep -rl '@vaiftech/client' src | xargs sed -i 's|@vaiftech/client|@vaifstudio/client|g'3. Check against the current API
Section titled “3. Check against the current API”@vaifstudio/client has one constructor, createVaifClient, and no default export. Queries are chained and run with a final call such as list():
import { createVaifClient } from "@vaifstudio/client";import { upload } from "@vaifstudio/client/storage";
const vaif = createVaifClient({ projectId: process.env.VAIF_PROJECT_ID, apiKey: process.env.VAIF_PUBLISHABLE_KEY,});
const { data: posts } = await vaif.from("posts").eq("published", true).limit(20).list();
const input = document.querySelector<HTMLInputElement>("#avatar")!;await upload(vaif, "avatars", "users/42/avatar.png", input.files![0]);
console.log(posts.length);- Uploads are in
@vaifstudio/client/storage, and browser helpers (file pickers and drop zones) in@vaifstudio/client/storage/browser. - Realtime is on the client:
vaif.from(table).on(...)andvaif.channel(name). See Realtime. vaif.auth.signUpsigns up your app’s users and needsprojectId. VAIF Studio accounts are created in the console.
4. Verify
Section titled “4. Verify”Run your type checker (npx tsc --noEmit) and your tests. A method that moved or was renamed shows up as a type error.
Questions? Email support@vaif.studio.