Building for KaiOS using modern tools can be challenging. Most KaiOS devices run KaiOS 2.5 which is based on Firefox 48, initially released nearly a decade ago in 2016. However, KaiOS includes several modern features like Promisesand CSS grid that don’t perfectly align with it’s base Gecko engine.
Building KaiOS apps often requires a transpiler like
Babel, but to make things even more complicated, KaiOS uses a number of non-standard APIs or APIs based on outdated specifications. That’s where
kaios-types can help!
Introducing kaios-types
kaios-types is an open-source–
Apache 2.0 licensed–library containing
TypeScript type declarations for most KaiOS 2.5 APIs. It’s hosted on
NPM where it can be installed and configured for any codebase.
kaios-types provides more confidence developing KaiOS apps with type safety. It also leverages
TSDoc syntax for documentation and is structured in a way to support
IntelliSense, enabling Visual Studio Code to provide structured code completion.
Installation
NPM
1npm install --save-dev kaios-types
PNPM
1pnpm add kaios-types --save-dev
Bun
1bun add --development kaios-types
Configuration
Add the types to your tsconfig.json:
1{
2 "compilerOptions": {
3 "types": ["kaios-types"]
4 }
5}
Or use a triple-slash directive at the top of your TypeScript files:
1/// <reference types="kaios-types" />
2
3// Now KaiOS APIs are available with full type checking
4const settings = navigator.mozSettings;
5settings.createLock().set({ 'wifi.enabled': true });
Modular Imports
You can also import specific types directly:
1import { MozActivity, ActivityOptions } from 'kaios-types/apps/moz-activity';
2import { BluetoothManager } from 'kaios-types/bluetooth/bluetooth-manager';
3
4const activity = new MozActivity({
5 name: 'pick',
6 data: { type: 'image/jpeg' }
7});
Conclusion
Building KaiOS apps just got easier with kaios-types. However, feature phone web development remains fragments across three major KaiOS versions–2.5, 3.0, and 4.0–in addition to Cloud Phone. If you need a partner to assist in flip phone development, contact the author from the
About page.