NextGram/plugins Start here Quick start

Quick start

Build, sign and install a working TypeScript plugin in about ten minutes.

This is the shortest path to a plugin that builds, installs and appears in NextGram settings. You need Node.js 22 or newer, pnpm, and a device with a recent NextGram Android build. The examples use TypeScript; Java and hybrid packages follow the same package and signing rules.

What you will make#

A declarative settings screen with no host permissions beyond ui.settings. The plugin is one signed .ngp file. The host evaluates the bundle, calls onLoad and renders the screen you return.

1. Get the toolchain#

Clone the app repository with its submodules and build the TypeScript workspace once:

bash
git clone --recursive https://github.com/gitwelk/NextGram.git
cd NextGram/NextGram-android/nextgram-plugin-ts
pnpm install
pnpm build

The workspace contains @nextgram/plugin (types and UI helpers) and @nextgram/cli (the nextgram-plugin command). A plugin project normally lives in this workspace so workspace:* dependencies resolve.

2. Start from the template#

bash
cp -R templates/typescript-template examples/my-hello
pnpm install
cd examples/my-hello

examples/* is part of the pnpm workspace, so workspace:* dependencies resolve and the template tsconfig.json extends the shared base config.

Open plugin.json and change the identity:

json
{
  "format": "ngp",
  "formatVersion": 1,
  "id": "dev.example.hello",
  "name": "Hello NextGram",
  "version": "1.0.0",
  "versionCode": 1,
  "kind": "ts",
  "api": 1,
  "minHost": ">=13.4.0",
  "platforms": ["android"],
  "description": "A minimal declarative settings screen.",
  "author": { "name": "Example Author" },
  "license": "MIT",
  "icon": "assets/icon.png",
  "script": "script/main.js",
  "permissions": ["ui.settings"]
}

Replace assets/icon.png with your own 512×512 PNG or WebP. The icon must stay under assets/, be at most 2 MB and be no larger than 1024×1024.

3. Write the entry point#

Replace src/index.ts:

ts
import { column, definePlugin, text } from "@nextgram/plugin";

export default definePlugin({
  async onLoad(ctx) {
    ctx.contributions.addSettingsEntry({
      id: "hello",
      title: "Hello NextGram",
      subtitle: "A plugin is running",
      icon: { type: "asset", path: "assets/icon.png" },
      screen: () =>
        column({
          style: { padding: 16, gap: 8 },
          children: [
            text("Hello from a signed .ngp package.", {
              style: { fontSize: 17, fontWeight: "medium" },
            }),
            text("This screen is built from declarative nodes, not Android views."),
          ],
        }),
    });
  },
});

definePlugin assigns the plugin object to globalThis.__ngp_plugin__ when the host evaluates the bundle. onLoad has a one second budget. Exceptions, timeouts and sandbox violations disable the plugin.

4. Build and pack#

bash
pnpm build
pnpm pack --unsigned
pnpm verify build/*.ngp

build runs the type checker, bundles one IIFE into script/main.js and validates the manifest. pack --unsigned is for developer-mode installs only. A normal install requires a signature; see Build & sign.

5. Install on the device#

  1. Copy the .ngp to the device and open it from a file manager, or send it to yourself and tap the document, or use NextGram Settings → Plugins → Install from file.
  2. Read the consent screen: publisher key fingerprint, version, permissions and the trusted-code warning when applicable.
  3. Install, enable the plugin and restart if the app asks. TypeScript-only plugins reload live; restart is needed when a DEX payload changes.
  4. Open NextGram Settings → Plugins and find Hello NextGram.

6. Iterate#

bash
nextgram-plugin dev --push

dev watches the source, rebuilds and can push the package over adb. Keep the plugin manager open; three caught failures disable a plugin, and two interrupted boots enter safe mode.

Before you publish#

  • Bump versionCode on every version. The catalog and the manifest must agree.
  • Sign with the same key for every release of a plugin ID. A different key is a different publisher and cannot update the installed package.
  • Request only permissions the plugin uses. ui.screens is high risk and off at install.
  • Run the full preflight in Build & sign and the catalog rules in Catalog & updates.

Next#