Hello MIT App Inventor Builders! ![]()
Tired of slow Google Sheets, complex Firebase rules, or expensive server limits? Today, I am thrilled to introduce Cloudflare Database Extension (v2.0) for App Inventor, Kodular, and Niotron!
This extension directly connects your mobile apps to Cloudflare D1 (Cloudflare's ultra-fast, serverless, globally distributed SQLite database) via high-performance Cloudflare Workers. Experience lightning-fast query execution, multi-table queries, column-level conditional updates/deletes, and concurrency-safe numeric increments with zero hassle!
Key Features
Blazing Fast Global Edge Performance: Powered by Cloudflare's global edge network for sub-millisecond response times worldwide.
Multi-Table Architecture: Manage multiple tables in a single D1 database. Fetch individual tables or all tables at once ("all").
Advanced Column-Based Operations: Update or Delete rows matching specific column values without needing row IDs (e.g., WHERE UserEmail = 'xyz').
Multi-Column Bulk Updates: Update multiple columns simultaneously with a simple JSON object.
Atomic Increment / Decrement: Concurrency-safe numeric updates (perfect for wallet balances, coin systems, view counts, and scores).
Enterprise-Grade Security: Authenticated with Bearer API tokens and custom Cloudflare Worker endpoints.
Built-in Device Security Check: One-time silent background activation via your registered Email and Item ID.
100% Lifetime Free: Free for personal and commercial applications.
Extension Specifications
Package: com.abid.cloudflaredatabase
Version: 2.0
Size: 34.42 KB(Ultra-lightweight)
Minimum API Level: 14+(Android 4.0+)
Companion Friendly: Yes (Auto-verified in live companion testing)
Blocks Overview













![]()
![]()
![]()
![]()
![]()
Detailed Blocks & Documentation
Properties (Designer & Blocks)
| Property | Type | Description |
|---|---|---|
| ApiUrl | Text | The HTTPS endpoint URL of your deployed Cloudflare Worker. |
| ApiSecret | Text | The secret Bearer authorization token used to authenticate requests. |
CRUD & Database Methods
-
FetchData (tableName, id):
Retrieves data from your D1 database. Pass"all"to fetch all tables at once, or provide a specifictableName. Setidto empty""to retrieve all rows, or specify an ID for a single record.- Triggers:
OnDataFetched(response, tableName)
- Triggers:
-
StoreData (tableName, jsonData):
Inserts a new row into the specified table using a JSON string.- Example:
{"name":"Ali", "email":"ali@example.com", "balance": 100} - Triggers:
OnDataStored(response, tableName)
- Example:
-
UpdateData (tableName, id, jsonData):
Updates a record matching the primary ID with the provided JSON payload.- Triggers:
OnDataUpdated(response, tableName)
- Triggers:
-
DeleteData (tableName, id):
Deletes a record matching the primary ID.- Triggers:
OnDataDeleted(response, tableName)
- Triggers:
Advanced Column-Level Methods
-
UpdateByColumn (tableName, whereColumn, whereValue, updateColumn, updateValue):
Updates a specific column where another column matches a value.- Example: Set
PaymentStatus="Paid"whereTransactionID="TXN-98765". - Triggers:
OnDataUpdated(response, tableName)
- Example: Set
-
UpdateMultipleByColumn (tableName, whereColumn, whereValue, jsonUpdates):
Updates multiple columns at once using any unique column value.- Example: Where
UserEmail="``ali@gmail.com``", update Name, Phone, and City by passing{"Name":"Abid Ali", "Phone":"03449490070", "City":"Lahore"}. - Triggers:
OnDataUpdated(response, tableName)
- Example: Where
-
DeleteByColumn (tableName, whereColumn, whereValue):
Deletes rows where a target column matches a value.- Example: Delete from table
CartwhereUserEmail="``user@test.com``". - Triggers:
OnDataDeleted(response, tableName)
- Example: Delete from table
-
UpdateDataValue (tableName, uniqueColumn, uniqueValue, updateColumn, amount):
Atomically increments or decrements a numeric value in Cloudflare D1 without race conditions. Pass positive numbers (+10) to add, or negative (-5) to subtract.- Example: Add
50coins toWalletwhereUserID="U123". - Triggers:
OnValueUpdated(response, tableName)
- Example: Add
Security & Free Activation Blocks
| Method / Property | Return Type | Description |
|---|---|---|
| StartSecurityCheck (email, itemId) | None | Silently validates activation in background. Call in Screen.Initialize. |
| ForceRecheck (email, itemId) | None | Clears cache and re-validates credentials with the server. |
| ResetSecurityData () | None | Resets local device verification cache (for developer testing). |
| UserEmail () | Text | Returns the currently verified email address. |
| ItemID () | Text | Returns the registered Item ID. |
| IsVerified () | Boolean | Returns true if device has completed verification. |
| IsAccessGranted () | Boolean | Returns true if activation was approved. |
| IsSessionVerified () | Boolean | Returns true if active session is verified. |
Events
- OnDataFetched (response, tableName): Returns fetched data array / JSON.
- OnDataStored (response, tableName): Triggered after insertion completes.
- OnDataUpdated (response, tableName): Triggered after standard or column updates.
- OnDataDeleted (response, tableName): Triggered after row deletion.
- OnValueUpdated (response, tableName): Triggered when a numeric value is incremented or decremented.
- OnError (errorMsg): Fires when an error occurs during API execution.
- AccessGranted (): Fires when free registration verification succeeds. Safely load your app data here!
- AccessDenied (email, itemId): Fires if verification fails or unverified credentials are used.
Complete Step-by-Step Setup Guide
Step 1: Get Backend Script & Free Activation
- Visit our official store:
AIX Hub Store - Cloudflare Database - Click the orange button: Download ZIP (.zip) to download the complete Cloudflare Worker JavaScript file (
worker.js). - Enter your email in the registration box and click Save to activate your free lifetime Item ID.
Step 2: Setup Cloudflare D1 Database & Worker
-
Log in to your free account at dash.cloudflare.com.
-
Go to Workers & Pages > D1 SQL Database > Click Create Database (give it a name, e.g.
mydb). -
Go to Workers & Pages > Click Create Application > Create Worker > Click Deploy.
-
Click Quick Edit and paste the code from the downloaded
worker.jsfile. -
In your Worker's Settings > Bindings, click Add Binding > select D1 Database, set the Variable name to
DB, and link your database. -
Set your custom secret password inside the script:
const API_SECRET = "YourSecurePasswordA3224gS"; -
Click Save and Deploy. Your Worker endpoint (e.g.
https://your-worker.workers.dev) is your ApiUrl, and the password you chose is your ApiSecret!
Step 3: Use in App Inventor
-
Drop
CloudflareDatabaseonto your screen. -
In Properties, set your
ApiUrlandApiSecret. -
In
Screen1.Initialize, callStartSecurityCheckwith your registered email and Item ID (Cloudflare Database). -
In
AccessGranted, callFetchData("users", "")or start inserting/updating records!
Download & Free Activation
This extension and the backend script are 100% FREE for everyone:
-
Download Extension (.aix):
com.abid.cloudflaredatabase.aix (35.7 KB)
-
Download Backend Script (.zip) & Free Lifetime Registration:
Visit AIX Hub Store to Download ZIP & Register
(Click 'Download ZIP (.zip)' for the worker script, and click 'Save' to activate your email). -
Example Project (.aia): Coming soon
Support & Feedback
If you encounter any bugs, have questions, or need assistance, feel free to reply to this thread!
WhatsApp Support: +923449490070
If this extension powers up your apps, don't forget to Like (
) this thread! Happy Coding! ![]()











