Skip to main content

Overview

Apps in cuse are modular components that can be installed and run on a virtual computer. Each app is an instance of a class that extends the abstract App class and implements its core lifecycle methods.

Creating an App

To create a custom app, extend the App class and implement the required methods:

Configuration

When creating an app, you must provide an AppConfig:

Lifecycle Methods

Each app must implement three core lifecycle methods:
  • install(): Called when the app is first initialized. Use this to install dependencies or set up the app environment.
  • start(): Called when the app should start running, either automatically if autoStart is true or manually.
  • stop(): Called when the app should shut down, typically when the computer is shutting down.

Using Apps with a Computer

To use your apps with a Computer instance, first define an interface for your app collection:

Accessing the Computer

Inside your app, you can access the computer instance through this.computer:

Example: Browser App

Here’s a complete example of a browser app that installs and controls a web browser:

Best Practices

  1. Error Handling: Implement proper error handling in all lifecycle methods
  2. Cleanup: Ensure the stop() method properly cleans up all resources
  3. Idempotency: Make the install() method idempotent - it should be safe to call multiple times
  4. Documentation: Document any custom methods and requirements for your app
  5. Dependencies: Clearly specify any system dependencies your app requires