# Vybase > Backend for apps, made for vibe coders: sign-in (email + password, email code, SMS, WhatsApp, Google, Continue with > Zyvraon), hosting, database, storage, email and functions (server code, cron, triggers). API URL: https://auth.zyvraone.site Website & Docs: https://vybase.zyvraone.site/ (Features: /features/, Compare vs Supabase & Firebase: /compare/, Full AI Guide: https://vybase.zyvraone.site/llms-full.txt) Dashboard: create a project, copy its publishable key (pk_…) from API keys. ## Easiest: the hosted login page (recommended for AI-built apps) Do not build a login form. Load the SDK on every page and call signInWithHostedPage(): import { createClient } from "https://console.zyvraone.site/sdk/vybase.js" const zyv = createClient("https://auth.zyvraone.site", "") signInButton.onclick = () => zyv.auth.signInWithHostedPage() // returns to this same page, signed in zyv.auth.onAuthStateChange((event, session) => { if (event === "SIGNED_IN") showApp(session.user) }) Plain HTML, one tag: localhost needs no setup; add the live site in console → Auth → URL configuration. ## JavaScript / TypeScript (browser, React, Next.js, Node) npm install @vybase/js import { createClient } from "@vybase/js" const zyv = createClient("https://auth.zyvraone.site", "") zyv.auth.signUp({ email, password, metadata?, redirectTo? }) -> { data: { user, session | null, verification_required? }, error } zyv.auth.signInWithPassword({ email, password }) zyv.auth.signInWithOtp({ email }) | ({ phone: "+923001234567", channel: "sms" | "whatsapp" }) zyv.auth.verifyOtp({ email, code }) | ({ phone, code }) zyv.auth.signInWithOAuth({ provider: "google" | "zyvraon", redirectTo }) // browser redirect; the SDK finishes on return (?code=) zyv.auth.signInWithIdToken({ provider: "google", token }) // native Google sign-in on Android/iOS zyv.auth.resetPasswordForEmail({ email, redirectTo }) // then on event "PASSWORD_RECOVERY": zyv.auth.updateUser({ password }) zyv.auth.resendVerification({ email, redirectTo }) zyv.auth.getSession() zyv.auth.getUser() zyv.auth.updateUser({ metadata?, password? }) zyv.auth.signOut({ scope?: "global" }) zyv.auth.onAuthStateChange((event, session) => {}) // SIGNED_IN, SIGNED_OUT, TOKEN_REFRESHED, USER_UPDATED, PASSWORD_RECOVERY zyv.auth.getSettings() // which sign-in methods the project has turned on Server only (secret key sk_…): zyv.auth.admin.listUsers / getUser / createUser / updateUser({ banned }) / deleteUser / signOutUser ## Rules - Methods never throw for API errors; they return { data, error }. Branch on error.code: email_taken, invalid_credentials, email_not_verified, otp_invalid, rate_limited, provider_disabled, redirect_not_allowed, sms_unavailable, whatsapp_unavailable, user_banned, session_expired, validation_failed. - pk_ keys are public (browsers, apps). sk_ keys are secret (servers only). - redirectTo must be the project's Site URL or listed under Auth → URL configuration. - Phone numbers are international format: +. ## Verify a user's token on your backend Access tokens are ES256 JWTs. JWKS: https://auth.zyvraone.site/.well-known/jwks.json, issuer: https://auth.zyvraone.site, audience: . Claims: sub (user id), pid (project id), email, phone, sid (session id), exp (15 minutes). ## Login with Zyvraon (OpenID Connect, for any app) Discovery: https://auth.zyvraone.site/.well-known/openid-configuration — register an OAuth app in the dashboard (Account → OAuth apps). ## Hosting (static sites: React/Vite, Flutter web, exported Next.js, plain HTML) 1. Build: npm run build (or flutter build web). 2. Deploy: npx vybase deploy --site (creates .zyvraone.site; add --preview for a preview link) The CLI finds dist/, build/, out/, public/ or build/web by itself; .env files and node_modules are never uploaded. AI assistants with the Vybase MCP server: call deploy_site { site, cwd }. 3. Optional vybase.json in the build folder: { "spa": true, "redirects": [{ "source": "/old/:slug", "destination": "/new/:slug" }], "rewrites": [{ "source": "/app/*", "destination": "/app.html" }], "headers": [{ "source": "/*", "headers": [{ "key": "X-Frame-Options", "value": "DENY" }] }] } Single-page apps (React Router) need "spa": true. A 404.html in the folder is used for missing pages. Previews: --.zyvraone.site · one exact deployment: --<8-char id>.zyvraone.site. Rollback: vybase rollback (instant). Own domain: vybase domains add example.com. ## Storage (files and images) Make a bucket in the console (Storage → New bucket): public (anyone with the link sees files) or private, who may upload (default: signed-in users, only inside their own folder /…), max size and allowed types (image/*). const zyv = createClient(url, pk, { projectId: "" }); await zyv.storage.from("avatars").upload(`${user.id}/me.png`, file, { upsert: true }); zyv.storage.from("avatars").getPublicUrl(`${user.id}/me.png`, { width: 256 }) // resized, WebP/AVIF when supported await zyv.storage.from("docs").createSignedUrl("/cv.pdf", 3600) // private file, link for 1 hour .download(path) · .remove(path) · .list(prefix) Servers use the sk_ key and may read/write anything. Errors: storage_forbidden (403), file_type_not_allowed (415), file_too_large (413), file_exists (409, pass upsert), storage_full (507, plan limit: Free 1 GB, Pro 100 GB). REST: POST|GET|DELETE /storage/v1/object// (raw body), GET /storage/v1/list/?prefix=, POST /storage/v1/sign// { expires_in }, public: GET /storage/v1/public///?w=&q= ## Database (your app's data) Collections of JSON documents (like Firestore). Create a collection in the console (Database → New collection) and pick its rules. Read: public | authenticated | owner | server. Write: authenticated | owner | server. Default owner/owner: signed-in users see and change only their own documents (the server sets owner_id). The sk_ key bypasses rules. const { data, error } = await zyv.db.from("todos").insert({ title: "Buy milk", done: false }); const { data: rows, nextCursor } = await zyv.db.from("todos").select({ where: [["done", "eq", false], ["tags", "contains", "home"]], order: ["created_at", "desc"], limit: 20 }); await zyv.db.from("todos").get(id) // one document await zyv.db.from("todos").update(id, { done: true }) // merge; a field set to null is removed await zyv.db.from("todos").set(id, doc, { upsert: true }) await zyv.db.from("todos").delete(id) const sub = zyv.db.from("chat").subscribe((c) => console.log(c.type, c.doc)); sub.unsubscribe() // live Filter ops: eq, neq, gt, gte, lt, lte, in (array), contains (list field has the value), like (case-insensitive text); nested fields with dots (address.city). limit 1–100 (default 50), cursor paging, fields, count. Documents come back as { id, ...your fields, owner_id, created_at, updated_at }. At most 1 MB, 8 levels deep. REST: x-zyvraon-key: (+ Authorization: Bearer ) POST /db/v1/[?id=] · GET /db/v1/?where=done.eq.false&order=created_at.desc&limit=20&cursor= GET|PATCH|PUT[?upsert=true]|DELETE /db/v1// · live: GET /db/v1/_realtime/ (Server-Sent Events) Errors: collection_not_found (404), document_not_found (404), sign_in_required (401), db_forbidden (403), db_invalid_query (400), db_invalid_document (422), document_too_large (413), db_full (507, Free 500 MB, Pro 20 GB), rate_limited (429). ## Backend as one file: vybase.config.json The whole backend (sign-in, database collections, storage buckets, email templates) in one file next to your code. JSON Schema: https://auth.zyvraone.site/schema/vybase.config.v1.json (add it as "$schema" for editor help). { "$schema": "https://auth.zyvraone.site/schema/vybase.config.v1.json", "version": 1, "project": "prj_…", "auth": { "methods": { "google": true, "email_otp": true, "zyvraon": true }, "app_name": "My Shop", "site_url": "https://myshop.in", "redirect_urls": ["https://myshop.in/auth/callback"] }, "database": { "collections": { "orders": { "read": "owner", "write": "owner", "fields": { "item": { "type": "string", "required": true } } }, "menu": { "read": "public", "write": "server" } } }, "storage": { "buckets": { "photos": { "public": true, "allowed_types": ["image/*"], "max_file_mb": 5 } } }, "email": { "templates": { "welcome": { "subject": "Welcome, {{name}}!", "html": "

Hi {{name}}

" } } } } npx vybase config pull --project # write the project's current backend to the file npx vybase config plan # what a push would change (changes nothing) npx vybase config push [--yes] # make the project match the file npx vybase config history · npx vybase config revert Rules: left-out sections aren't touched; listed collections/buckets match the file exactly (left-out fields = defaults: read/write "owner", buckets private, 10 MB, any type). --prune deletes what the file doesn't list, except collections with documents and buckets with files. Unknown keys are errors. No secrets go in the file. REST: GET|POST https://auth.zyvraone.site/v1/platform/projects//config[/plan|/apply] with a personal access token. Errors: config_invalid (422), config_drift (409, plan again), config_wrong_project (409). ## Security check and TypeScript types npx vybase check # risky settings, each with its fix (also: GET /v1/platform/projects//advisor) npx vybase types # writes vybase.d.ts; then zyv.db.from("orders").insert({ … }) Leaked-password protection is on by default: sign-up and password changes refuse passwords found in data breaches (error password_pwned). Turn off with auth.leaked_password_protection: false in vybase.config.json. ## Email (send from your app's server) Vybase delivers your app's emails, no provider to set up. Secret key (sk_…) only: never from a browser. const zyv = createClient(url, process.env.VYBASE_SECRET_KEY); await zyv.email.send({ to: "asha@example.com", subject: "Welcome!", html: "

Hi Asha

", text: "Hi Asha" }); await zyv.email.send({ to: user.email, template: "welcome", data: { name: "Asha" } }) // template from the console await zyv.email.get(id) // status: sent, delivered, bounced, complained, failed, suppressed Fields: to (one address or up to 50, each gets its own email), subject, html, text, template, data, from ("Name " on a domain verified in Email → Domains; default " "), reply_to, kind ("transactional" default, or "marketing": adds an unsubscribe link and List-Unsubscribe header). Also: cc, bcc (with one "to"), headers (X-…), tags { name: value } (up to 10), attachments [{ filename, content (base64), content_type?, content_id? (inline: ) }] (10 files, 10 MB), scheduled_at (ISO, up to 30 days). await zyv.email.send(msg, { idempotencyKey: "order-42/confirm" }) // a retry within 24 h never sends twice await zyv.email.batch([msg1, msg2]) // up to 100, no attachments/scheduling; one invalid → none sent await zyv.email.cancel(id) · await zyv.email.reschedule(id, date) A text version is made from the HTML when you send none. Template placeholders {{name}} are filled from data (HTML-escaped). Limits: Free 1,000 / Pro 50,000 recipients a month per account; new projects 100 a day for 7 days; 10 calls a second per project. Test addresses (not counted): delivered@ / bounced@ / complained@test.vybase. Webhooks (console → Email → Webhooks): POST { id, type, created_at, data: { email_id, to (masked), subject, tags, … } } for email.sent, delivered, delivery_delayed, bounced, complained, opened, clicked, failed, scheduled, canceled, suppressed. Headers vybase-id, vybase-timestamp, vybase-signature (v1,): if (!(await zyv.email.verifyWebhook(rawBody, req.headers, process.env.VYBASE_WEBHOOK_SECRET))) return 401 Open/click tracking: off by default, per project (console → Email → Settings). REST: POST https://auth.zyvraone.site/email/v1/send | /email/v1/batch with x-zyvraon-key: sk_… (optional Idempotency-Key header) · GET|PATCH /email/v1/messages/ · POST /email/v1/messages//cancel Errors: email_forbidden (403, not the secret key), email_invalid (422), email_limit (429), email_domain_not_verified (409), email_suppressed (422, the address bounced/complained/unsubscribed), email_paused (403, too many bounces or complaints), template_not_found (404), email_failed (502), idempotency_conflict (409), email_not_scheduled (409). ## Functions (server code: hide API keys, webhooks, payments, cron jobs, triggers) TypeScript or JavaScript, web standard (Supabase Edge Functions and Cloudflare Workers code mostly runs as is): // vybase/functions/ask-ai/index.ts export default async function (req: Request, ctx) { const { question } = await req.json(); const r = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${process.env.OPENAI_API_KEY}` }, body: JSON.stringify({ model: "gpt-4o-mini", messages: [{ role: "user", content: question }] }) }); return Response.json({ answer: (await r.json()).choices[0].message.content, user: ctx.user?.id }); } ctx: user (signed-in caller's token claims, or null), env, waitUntil(promise), executionId, trigger. Deno.serve(handler) and Deno.env.get() work too. Node built-ins (node:crypto …) and fetch; npm packages are bundled by the CLI on your computer. Deploy: npx vybase functions new ask-ai · npx vybase functions deploy ask-ai · npx vybase functions secrets set OPENAI_API_KEY=… Call from the app (sends the signed-in user's token): const { data, error } = await zyv.functions.invoke("ask-ai", { body: { question: "Hi" } }) await zyv.functions.invoke("report", { body, background: true }) // 202 at once, runs with 3 tries Address (webhooks, any client): https://auth.zyvraone.site/functions/v1//[/sub/path] — or https://auth.zyvraone.site/functions/v1/ with x-vybase-key. On your Vybase site, same origin: vybase.json { "rewrites": [{ "source": "/api/*", "function": "api" }] }. Access per function: signed_in (default; needs Authorization: Bearer ), public (anyone; for webhooks), secret (only your server, x-vybase-key: sk_…). CORS is answered for you (origins list per function). Secrets: process.env.NAME (console → Functions → Secrets, or the CLI). Every function also has VYBASE_URL, VYBASE_PROJECT_ID, VYBASE_PUBLISHABLE_KEY and VYBASE_SECRET_KEY (server key for /db/v1 and /email/v1). Schedules (cron + time zone, e.g. "0 9 * * *" Asia/Kolkata): export async function scheduled(event, ctx) {} Triggers: export async function event(e, ctx) {} on auth.user.created | auth.user.deleted | auth.user.signed_in | db.insert | db.update | db.delete (per collection; e = { type: "INSERT", table, record, old_record }) | storage.object.created | storage.object.deleted (per bucket) | form.submitted. Tried 3 times (now, 30 s, 5 min). Auth hooks: before sign-up (return { allow: false, message }) and custom access token (return { claims: { … } }). Logs: every call with console output (Free 1 day, Pro 7 days). Rollback to any of the last 20 versions. Limits: Free 25 functions, 50k calls/month, 30 s, 256 MB, 5 at once, schedules every 5 min · Pro 250, 2M, 150 s, 512 MB, 25 at once, every minute. Bodies up to 6 MB. Only /tmp is writable; no localhost or private networks. Errors: sign_in_required (401), function_forbidden (401), function_not_found (404), function_not_deployed (409), function_paused (503), function_timeout (504), function_crashed (502), function_error (500), function_busy (429), function_calls_limit (429), rate_limited (429), function_build_failed (422), signup_blocked (403, before sign-up hook). ## Use Vybase from Claude, ChatGPT or Cursor Remote MCP connector: https://auth.zyvraone.site/mcp (OAuth sign-in with Zyvraon; no token to copy). Tools: get_backend_config, plan_backend_config, apply_backend_config, security_check, generate_types, list_users, auth_logs, site_analytics, list_projects, project_overview, get_connect_info, vybase_guide, redeploy, rollback, set_spa, add_redirect_url, set_site_url, enable_sign_in, disable_sign_in, create_bucket, create_collection, set_collection_rules, list_collections, query_documents, insert_document, list_functions, get_function_code, create_function, deploy_function, invoke_function, function_logs, set_function_secret, add_function_schedule, add_function_trigger, set_function_access, email_overview, list_sent_emails, create_email_template, add_email_domain, set_email_tracking, add_email_webhook, email_details, send_test_email, add_domain, build_android_app, list_recent_ai_actions, undo_action. ## REST Every /v1/auth call sends the header x-zyvraon-key: . Signed-in calls also send Authorization: Bearer . POST /v1/auth/signup, /v1/auth/login, /v1/auth/otp/send, /v1/auth/otp/verify, /v1/auth/refresh, /v1/auth/recover, /v1/auth/verify/resend, /v1/auth/token, /v1/auth/idtoken, /v1/auth/logout · GET/PATCH /v1/auth/user · GET /v1/auth/settings