Code editor showing appifio_client usage in page script
Injected Appifio client

Appifio Creator · Lesson T02 · Glossary

appifio_client
and bootstrap inject

The backend library is already injected into the page - the AI (and you) may call it, never rewrite the class.

Goals: Know why appifio_client is always there; use waitForAppStorage(); avoid a wrong typeof === 'undefined' check.

Before: T01, F01 · Next: T03 · UI labels: Backend tab · Ask AI about backend · Easy / Advanced

1. Inject flow

HTML page loads → App Storage Bootstrap runs BEFORE app content
→ creates window.appifio.global.apps (project code / Appifio link name, api_url, api_key, backend_version)
→ defines getter window.appifio_client
→ client script not ready yet: returns proxyClient (queues calls)
→ ready: returns the real clientInstance
You/AI: await waitForAppStorage() then call appifio_readList / appendData…

2. Glossary

TermMeaningWhere you see it
Bootstrap injectSystem script auto-injected into every app pageNo button - always runs on live/preview
appifio_clientObject that calls Storage APIs (DB + file store + auth + routes)Console / AI-generated code
proxyClientQueue while the real client is still loadingHidden - why typeof always “exists”
waitForAppStorage()Promise that waits until the client is readyGlobal bootstrap helper
encoded_key / api_keyPage-session token (not the admin token)Backend tab · “Your backend API key”

3. Verify it (no coding background required)

  1. Open Creator → Backend tab - confirm an API key and Easy or Advanced.
  2. Open the Current preview (after Save) → F12 Console → type: typeof appifio_client → always "object" (getter), never undefined.
  3. Type: await waitForAppStorage() then try await appifio_client.appifio_listFiles() (or the matching method) - with the right Easy/Advanced permissions you get a result.
  4. In chat, pick mode Coder or click Ask AI about backend (Backend tab) and ask: “Use the existing appifio_client - do NOT redefine class AppStorageClient.”
  5. If the AI invents class AppStorageClient or raw fetch() to an endpoint → reject the Diff (✗) and restate Aura Storage rules.

4. Right / wrong in code

✅ Right❌ Wrong
await waitForAppStorage() then call methodstypeof appifio_client === 'undefined'
Call appifio_appendData / appifio_readListRaw fetch to the API (skips auth and rate limits)
Use project code / Appifio link name from window.appifio.global.appsHardcode a slug for the wrong environment

5. Comparisons

  • Firebase / Supabase client SDK: you import it yourself; Appifio injects it.
  • Bubble: data layer stays behind the visual builder; Appifio exposes a deliberate JS API for AI and coders.
  • WordPress REST: you handle auth yourself; here page session and admin token are separate layers.

6. Can / can’t · Security

You can: CRUD JSON, site file store, routes, admin auth, upload (with the right role), backend functions. You can’t: rewrite the client; ask the AI to disable send limits; read passwords in clear text.

Security: The Backend-tab API key is scoped to the app - don’t paste it publicly; keep the page api_key distinct from the admin token after login.

7. Common issues

SituationFix
Code runs “too early” and failsawait waitForAppStorage(); bootstrap already queues work past DOMContentLoaded
AI invents a new clientReject Diff; insist on the existing appifio_client (don’t rewrite the library)
Easy vs Advanced behaves differentlyCheck the Backend tab · lesson T06

8. Tips · Checklist

  • Fixed prompt: “Use the existing appifio_client - do not rewrite appifio_* methods.”
  • Always try/catch and show a friendly message when a rate limit hits.
  1. Do you know why typeof appifio_client === 'undefined' is always wrong?
  2. Can you open the Backend tab and see the API key?

Next: T03 - Flat JSON vs Indexed

Appifio Creator · User guide · T02