Skip to content

feat(create): scaffold backend-and-client with the editor-app client convention - #578

Open
davidsu wants to merge 1 commit into
mainfrom
feat/scaffold-editor-convention
Open

feat(create): scaffold backend-and-client with the editor-app client convention#578
davidsu wants to merge 1 commit into
mainfrom
feat/scaffold-editor-convention

Conversation

@davidsu

@davidsu davidsu commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Note

Description

The backend-and-client scaffold now follows the same client convention that editor-created apps use, so a CLI-created app and an editor-created app share one frontend wiring story. Instead of baking the app id into src/api/base44Client.js at scaffold time, the template resolves app params (app id, access token, functions version, app base url) at runtime and talks to the backend over same-origin /api via @base44/vite-plugin. Under base44 dev the plugin proxies /api to the local dev backend, so scaffolded apps get local entities and functions out of the box.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe): template + template-dependency change; affects newly scaffolded projects only, existing projects are untouched

Changes Made

  • src/api/base44Client.js - replaced the EJS-templated client (base44Client.js.ejs, which inlined appId: <%= projectId %>) with a static file that builds the client from appParams: serverUrl: "" (same-origin /api), requiresAuth: false, plus appId / token / functionsVersion / appBaseUrl. The app id is no longer written into source - it resolves from env or base44/.app.jsonc.
  • src/lib/app-params.js (new) - resolves each app param from URL query string -> localStorage -> Vite env default (VITE_BASE44_APP_ID, VITE_BASE44_FUNCTIONS_VERSION, VITE_BASE44_APP_BASE_URL), strips access_token from the URL after reading it, caches values under base44_* keys, and clears the stored token when clear_access_token=true. Guarded for non-browser (typeof window === "undefined") evaluation.
  • vite.config.js - added @base44/vite-plugin to the plugin list and dropped the hand-rolled @ -> ./src alias and the path import; the plugin supplies the alias and the /api dev proxy (jsconfig.json already declares @/* for editors).
  • package.json - bumped @base44/sdk ^0.8.3 -> ^0.8.40 and added @base44/vite-plugin ^1.0.30.
  • packages/cli/tests/cli/create.spec.ts - new integration test asserting a scaffolded backend-and-client project has serverUrl: "" and the @/lib/app-params import, does not contain the app id in base44Client.js, ships src/lib/app-params.js referencing the VITE_BASE44_* vars, wires @base44/vite-plugin in vite.config.js, and still writes the app id into base44/.app.jsonc.
  • CHANGELOG.md - added a ### Changed entry describing the new template convention.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

  • base44 dev already injects VITE_BASE44_APP_ID and VITE_BASE44_APP_BASE_URL into the frontend serveCommand (packages/cli/src/cli/dev/dev-server/main.ts), which is what the new app-params.js defaults read - the two halves line up. base44 eject also writes VITE_BASE44_APP_ID.
  • requiresAuth: false keeps the scaffold anonymously browsable; apps that need a signed-in user should flip it to true.
  • src/lib/app-params.js is intentionally kept close to the editor-app version (tabs, //-style comment in the client) so the two conventions do not drift; it is not reformatted to the CLI repo Biome style.
  • The @base44/vite-plugin dependency is a template dependency (installed in scaffolded user projects), not a CLI dependency, so the zero-dependency distribution rule is unaffected.
  • No docs/ updates: this changes template contents only, not CLI architecture.
  • Verification note: bun run build and the test suite were not executed in this environment (command approval was declined), so the two unchecked Testing boxes reflect what I could confirm from the diff rather than a known failure.

🤖 Generated by Claude | 2026-07-27 11:20 UTC | e827f85

…convention

Converge the scaffold's runtime wiring with editor-generated apps so the
two species stay portable: @base44/vite-plugin in vite.config.js, the
verbatim src/lib/app-params.js boilerplate, and a client that talks
same-origin /api (serverUrl: '') instead of a source-baked app id.

Under `base44 dev` the plugin proxies /api to the injected local backend
URL, so scaffolded apps now hit local entities and functions. The app id
resolves at dev/build time from VITE_BASE44_APP_ID / base44/.app.jsonc
(plugin fallback) rather than being rendered into base44Client.js.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.1.5-pr.578.bad1ac7

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.1.5-pr.578.bad1ac7"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.1.5-pr.578.bad1ac7"
  }
}

Preview published to npm registry — try new features instantly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant