Exporting Code

Export turns your design into a real project for the platform the app is built for: Flutter, Expo (React Native) or the web (React). Each is a project a team would keep, with a clear line between the files Koolbase regenerates and the files that are yours.

Choosing the platform

An app is built for one platform at a time. Pick it under Build for, in the App section of the Designer's left panel. The design stays the same; Export, the checks and the components on offer follow the platform you pick.

What you own, what Koolbase owns

Every export has the same rule. A few folders are Koolbase's and are replaced whole on every export. Everything else — the entry point, the package file, the README, any screen or file you write yourself — is yours: Koolbase writes it once, with the first export, and never touches it again.

PlatformKoolbase's (replaced on export)Built with
Flutterlib/generated/, test/generated/, lib/l10n/app_en.arbRiverpod, go_router, ARB strings, koolbase_flutter
Exposrc/generated/, app/(koolbase)/Expo Router, React Native Paper, @koolbase/react-native
Websrc/generated/React, Vite, React Router, @koolbase/js

In the Expo and web exports, each file also starts with a comment saying whose it is.

Re-exporting without losing your work

Use the CLI. It replaces Koolbase's folders transactionally, leaves yours untouched, and refuses if you edited a generated file by hand — so a change never disappears silently. It reads which folders are Koolbase's from the export itself, so the same command works for all three platforms.

terminal
Bash
koolbase export apply ~/Downloads/koolbase_export.zip --into ./my_app

If you need to change a generated screen, copy it out of Koolbase's folder, edit the copy, and route to it — the next export will not touch your copy.

Flutter

project
text
lib/
  main.dart                 yours — three lines calling koolbaseMain()
  generated/                Koolbase's — replaced on export
    core/                   runtime helpers, l10n, mutations, app_state
    theme/                  tokens from the Designer's theme
    app/                    app.dart, routes.dart
    screens/                one file per screen (+ _state.dart when it has state)
    l10n/                   generated AppLocalizations
  l10n/
    app_en.arb              Koolbase's — every string, keyed by node id
    app_fr.arb              yours — add locales beside it
test/generated/             one smoke test per screen
.koolbase/export.json       what was generated, sha256 of each file

One shape, so a developer inheriting an export learns it once. No codegen: the providers and routes are written out, and the project builds anywhere Flutter does.

  • State — one Riverpod Notifier per screen with state, one AppState for values shared across screens; persisted values write through to shared_preferences; non-retained values reset on sign-out.
  • Mutations — every write, upload and function call runs through an AsyncValue notifier; pending is isLoading, failed is hasError, the error message maps through userMessageFor.
  • Routing — go_router with a typed class per screen: ProductRoute(productId: id).push(context).
  • Forms — validated fields are TextFormFields inside a Form: silent until first blur, live after, all revealed on submit.
  • Lists — KoolbaseCollectionList owns fetching, cache and refresh; search filters what it has loaded.

Keys follow ids, not names

Localization keys are anchored to screen and node ids. Rename a widget in the Designer and your app_fr.arb still matches. Equal English at two sites stays two entries — "Save" on an invoice and "Save" on a draft may translate differently.
terminal
Bash
flutter pub get
flutter gen-l10n
flutter analyze
flutter test
flutter run --dart-define=KOOLBASE_PUBLIC_KEY=pk_live_...

To run a Flutter export in a browser, once: flutter create . --platforms web (Koolbase never writes platform folders), then flutter run -d chrome --web-port 8080 and add http://localhost:8080 to your project's Trusted Origins in the dashboard. Code push and offline sync are not available in a browser; everything else is.

Or just press Run

You do not have to export to see the real thing. Run builds it for you and opens it in the Designer in two to three minutes. It does the same for Expo apps (as a web preview) and web apps.

Expo

An Expo project on Expo Router: each screen is a route under app/(koolbase)/, and the components, theme, app state and Koolbase setup live in src/generated/. Your project's public key goes in .env; the export includes a .env.example to copy.

.env
Bash
EXPO_PUBLIC_KOOLBASE_PUBLIC_KEY=pk_live_...
terminal
Bash
npm install
npx expo start

When you need a development build

Expo Go runs most apps as they are. Google and Apple sign-in and push notifications use native modules, and the app's own icon and launch screen only show in a real build, so for those run a development build: npx expo run:ios or npx expo run:android.

Web

A React app built with Vite, with a route per screen. Koolbase's files live in src/generated/; src/main.tsx, index.html and vite.config.ts are yours. Your project's public key goes in .env.

.env
Bash
VITE_KOOLBASE_PUBLIC_KEY=pk_live_...
terminal
Bash
npm install
npm run dev        # develop
npm run build      # a static site in dist/

Add the address you develop on (Vite's is http://localhost:5173) and the address you host on to your project's Trusted Origins in the dashboard. dist/ is plain files you can host anywhere: answer every path that is not a file with index.html, so a link straight to a screen opens it.

Or let Koolbase host it

You do not have to host a web app yourself. Deploy to the Web builds it and publishes it at its own address, from inside the Designer.

What the manifest says

Every export carries .koolbase/export.json: the platform, every generated file with its hash, which folders are Koolbase's, and the platform configuration you must add yourself — for example iOS usage strings when the app uses the camera or photo library, which Koolbase never writes.