App lifecycle methods

Rocketlane exposes lifecycle hooks that allow your app to respond to key events during its installation and removal. These methods enable you to handle setup tasks, perform cleanups, or trigger workflows when a user installs or uninstalls your app.

⚙️

Information point

These lifecycle methods should be defined in the eventHandlers object inside your app’s index.js file.

Available Lifecycle Events

  1. onAppInstall

Triggered immediately after a user installs your app from the Marketplace.

Use cases:

  • Initialize default settings
  • Register webhooks
  • Sync starter data
  • Log install metrics

Signature:

onAppInstall: {
  run: async (r, args) => { ... }
}

Parameters:

  • r – Rocketlane SDK runtime context
  • args – contains:
    • installationId: unique ID for the installed app
    • config: user-provided installation config values
    • context: metadata like account ID, user ID, etc.
  1. onAppUninstall

Triggered when the app is removed from a workspace.

Use cases:

  • Cleanup data or revoke access
  • Deregister webhooks
  • Clear background jobs
  • Log uninstall analytics

Signature:

onAppUninstall: {
  run: (r, args) => { ... }
}

Parameters:

  • r – Rocketlane SDK runtime context
  • args – contains:
    • installationId: the app instance being uninstalled
    • context: metadata related to the uninstalling user/account

Example

eventHandlers: {
  onAppInstall: {
    run: async (r, args) => {
      const { installationId, config, context } = args;
      console.log("App installed:", installationId);
      // Setup logic goes here
    }
  },
  onAppUninstall: {
    run: (r, args) => {
      const { installationId, context } = args;
      console.log("App uninstalled:", installationId);
      // Cleanup logic goes here
    }
  }
}

What’s Next