KapsulaExamplesAPIРусский

JAVASCRIPT · KAPSULA 0.4.0

Run JavaScript (.js) on Android or iPhone

Got a JavaScript script from AI? Kapsula 0.4.0 runs it without an HTML wrapper, separate build or developer account. Reopen the saved source, refine it and copy an error for your AI assistant.

Google Play · App Store

Your projects need Kapsula Pro: a monthly subscription with a 7-day trial for eligible new subscribers, or a lifetime purchase. Prices are shown in the app. The built-in demo is free.

From script to your own tool

  1. Update Kapsula to 0.4.0 from Google Play or the App Store. If your store still offers an earlier version, update before importing .js.
  2. Open Add project. To paste code, choose JavaScript (.js); alternatively select a .js file with the system file picker.
  3. Tap Run. Your script can build its UI inside #app; console output appears below it. The script defines the interface.
  4. Return to the list, open this project’s settings → Update code. The saved source is in the editor. Updating the same project keeps its storage; your code must handle older records if you change their format.
  5. If the script fails, the runner shows an error. Use Copy the error for your AI and paste it with the source into your own chat. Kapsula does not send code or data to an assistant automatically.

Try a ready-made JavaScript tool

A minimal example: counter

Save this as counter.js or paste it using JavaScript (.js). Tap +1, close and reopen the same project: its storage restores the count.

Download counter.js

await kapsula.ready;
const countKey = 'my-counter-v1';
let count = Number(await kapsula.storage.get(countKey)) || 0;
const app = document.getElementById('app');
app.innerHTML = '<h1>My counter</h1><p id="count"></p>' +
  '<button id="add">+1</button><p id="status" role="status"></p>';
const render = () => { document.getElementById('count').textContent = count; };
render();
document.getElementById('add').onclick = async function () {
  this.disabled = true;
  try {
    await kapsula.storage.set(countKey, count + 1);
    count += 1;
    render();
    document.getElementById('status').textContent = 'Saved';
  } catch (error) {
    document.getElementById('status').textContent = String(error.message || error);
  } finally {
    this.disabled = false;
  }
};

A prompt for your own JavaScript tool

Copy this prompt into your AI chat and replace the final line with your task.

TypeScript (.ts) is available in 0.5.0: guide and workout log →

Supported format

One plain JavaScript script without imports/exports or external dependencies. Top-level await works inside the Kapsula runner. Add CSS with a style element. HTML with CSS/JS remains supported as a separate format. TypeScript, React/JSX, npm projects and Python are not supported in 0.4.0. No camera, files/share, location or network bridge was added.

Phone features

The script uses the same API: project storage, up to 16 scheduled notifications, foreground sound and haptics. Request notifications through kapsula.notify.schedule; JavaScript does not run continuously in the background. Delivery and sound depend on OS permissions and settings. Test a short notification on your device.

There is no version history or code rollback yet. Save a working source copy before replacing it. Creating a new project does not copy the old project’s data.