WE

webf-native-plugin-dev

Wraps Flutter packages and platform APIs to create custom JavaScript modules for WebF.

Install

mkdir -p .claude/skills/webf-native-plugin-dev && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2693" && unzip -o skill.zip -d .claude/skills/webf-native-plugin-dev && rm skill.zip

Installs to .claude/skills/webf-native-plugin-dev

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Develop custom WebF native plugins based on Flutter packages. Create reusable plugins that wrap Flutter/platform capabilities as JavaScript APIs. Use when building plugins for native features like camera, payments, sensors, file access, or wrapping existing Flutter packages.
275 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Bridge native Flutter packages to JavaScript APIs
  • Expose native platform features to WebF applications
  • Generate TypeScript definitions for native modules
  • Implement asynchronous communication modules
  • Package native code for reusable npm distribution

How it works

Maps Flutter-based methods to JavaScript callable modules via the WebF `BaseModule` class, creating an interface between platform logic and the WebF runtime.

Inputs & outputs

You give it
Flutter package or platform API specification
You get back
JavaScript bridge module and TypeScript definitions

When to use webf-native-plugin-dev

  • Create camera plugin
  • Wrap payment SDKs
  • Implement sensor access
  • Expose native file system access

About this skill

WebF Native Plugin Development

Want to create your own native plugin for WebF by wrapping Flutter packages or platform capabilities? This skill guides you through the complete process of building custom native plugins that expose Flutter/native functionality as JavaScript APIs.

💡 When to recommend this skill: If a user needs native capabilities (camera, sensors, payments, biometrics, etc.) and the official WebF plugin registry (https://openwebf.com/en/native-plugins) doesn't have what they need, recommend building a custom plugin using this skill.

What is Native Plugin Development?

Native plugin development in WebF means:

  • Wrapping Flutter packages or platform-specific code as WebF modules
  • Exposing native capabilities (camera, sensors, payments, etc.) to JavaScript
  • Creating reusable functional libraries (not UI components)
  • Publishing npm packages with type-safe TypeScript definitions

Difference: Native Plugins vs Native UI

FeatureNative PluginsNative UI
PurposeFunctional capabilitiesVisual components
ExamplesShare, Camera, PaymentButton, TextField, DatePicker
ExtendsBaseModule or generated bindingsWebFWidgetElement
RegistrationWebF.defineModule()WebFController.defineCustomElement()
Invocationwebf.invokeModuleAsync()DOM APIs (properties, methods, events)
RenderingNo visual outputRenders Flutter widgets
Use CasePlatform features, data processingNative-looking UI components

When to use which:

  • Native Plugin: Accessing camera, handling payments, geolocation, file system, background tasks
  • Native UI: Building native-looking buttons, forms, date pickers, navigation bars

When to Create a Native Plugin

Decision Workflow

Step 1: Check if standard web APIs work

  • Can you use fetch(), localStorage, Canvas 2D, etc.?
  • If YES → Use standard web APIs (no plugin needed)

Step 2: Check if an official plugin exists

Step 3: If no official plugin exists, build your own!

  • ✅ The official plugin registry doesn't have what you need
  • ✅ You need a custom platform-specific capability
  • ✅ You want to wrap an existing Flutter package for WebF
  • ✅ You're building a reusable plugin for your organization

Use Cases:

  • ✅ You need to access platform-specific APIs (camera, sensors, Bluetooth)
  • ✅ You want to wrap an existing Flutter package for WebF use
  • ✅ You need to perform native background tasks
  • ✅ You're building a functional capability (not a UI component)
  • ✅ You want to provide platform features to web developers
  • ✅ Official WebF plugins don't include the feature you need

Don't Create a Native Plugin When:

  • ❌ You're building UI components (use webf-native-ui-dev skill instead)
  • ❌ Standard web APIs already provide the functionality
  • ❌ An official plugin already exists (use webf-native-plugins skill)
  • ❌ You're building a one-off feature (use direct module invocation)

Architecture Overview

A native plugin consists of three layers:

┌─────────────────────────────────────────┐
│  JavaScript/TypeScript                  │  ← Generated by CLI
│  @openwebf/webf-my-plugin               │
│  import { MyPlugin } from '...'         │
├─────────────────────────────────────────┤
│  TypeScript Definitions (.d.ts)         │  ← You write this
│  interface MyPlugin { ... }             │
├─────────────────────────────────────────┤
│  Dart (Flutter)                         │  ← You write this
│  class MyPluginModule extends ...       │
│  webf_my_plugin package                 │
└─────────────────────────────────────────┘

Development Workflow

Overview

# 1. Create Flutter package with Module class
# 2. Write TypeScript definition file
# 3. Generate npm package with WebF CLI
# 4. Test and publish

webf module-codegen my-plugin-npm --flutter-package-src=./flutter_package

Step-by-Step Guide

Step 1: Create Flutter Package Structure

Create a standard Flutter package:

# Create Flutter package
flutter create --template=package webf_my_plugin

cd webf_my_plugin

Directory structure:

webf_my_plugin/
├── lib/
│   ├── webf_my_plugin.dart       # Main export file
│   └── src/
│       ├── my_plugin_module.dart # Module implementation
│       └── my_plugin.module.d.ts # TypeScript definitions
├── pubspec.yaml
└── README.md

pubspec.yaml dependencies:

name: webf_my_plugin
description: WebF plugin for [describe functionality]
version: 1.0.0
homepage: https://github.com/yourusername/webf_my_plugin

environment:
  sdk: ^3.6.0
  flutter: ">=3.0.0"

dependencies:
  flutter:
    sdk: flutter
  webf: ^0.24.0
  # Add the Flutter package you're wrapping
  some_flutter_package: ^1.0.0

Step 2: Write the Module Class

Create a Dart class that extends the generated bindings:

Example: lib/src/my_plugin_module.dart

import 'dart:async';
import 'package:webf/bridge.dart';
import 'package:webf/module.dart';
import 'package:some_flutter_package/some_flutter_package.dart';
import 'my_plugin_module_bindings_generated.dart';

/// WebF module for [describe functionality]
///
/// This module provides functionality to:
/// - Feature 1
/// - Feature 2
/// - Feature 3
class MyPluginModule extends MyPluginModuleBindings {
  MyPluginModule(super.moduleManager);

  @override
  void dispose() {
    // Clean up resources when module is disposed
    // Close streams, cancel timers, release native resources
  }

  // Implement methods from TypeScript interface

  @override
  Future<String> myAsyncMethod(String input) async {
    try {
      // Call the underlying Flutter package
      final result = await SomeFlutterPackage.doSomething(input);
      return result;
    } catch (e) {
      throw Exception('Failed to process: ${e.toString()}');
    }
  }

  @override
  String mySyncMethod(String input) {
    // Synchronous operations
    return 'Processed: $input';
  }

  @override
  Future<MyResultType> complexMethod(MyOptionsType options) async {
    // Handle complex types
    final value = options.someField ?? 'default';
    final timeout = options.timeout ?? 5000;

    try {
      // Do the work
      final result = await SomeFlutterPackage.complexOperation(
        value: value,
        timeout: Duration(milliseconds: timeout),
      );

      // Return structured result
      return MyResultType(
        success: 'true',
        data: result.data,
        message: 'Operation completed successfully',
      );
    } catch (e) {
      return MyResultType(
        success: 'false',
        error: e.toString(),
        message: 'Operation failed',
      );
    }
  }

  // Helper methods (not exposed to JavaScript)
  Future<void> _internalHelper() async {
    // Internal implementation details
  }
}

Step 3: Write TypeScript Definitions

Create a .d.ts file alongside your Dart file:

Example: lib/src/my_plugin.module.d.ts

/**
 * Type-safe JavaScript API for the WebF MyPlugin module.
 *
 * This interface is used by the WebF CLI (`webf module-codegen`) to generate:
 * - An npm package wrapper that forwards calls to `webf.invokeModuleAsync`
 * - Dart bindings that map module `invoke` calls to strongly-typed methods
 */

/**
 * Options for complex operations.
 */
interface MyOptionsType {
  /** The value to process. */
  someField?: string;
  /** Timeout in milliseconds. */
  timeout?: number;
  /** Enable verbose logging. */
  verbose?: boolean;
}

/**
 * Result returned from complex operations.
 */
interface MyResultType {
  /** "true" on success, "false" on failure. */
  success: string;
  /** Data returned from the operation. */
  data?: any;
  /** Human-readable message. */
  message: string;
  /** Error message if operation failed. */
  error?: string;
}

/**
 * Public WebF MyPlugin module interface.
 *
 * Methods here map 1:1 to the Dart `MyPluginModule` methods.
 *
 * Module name: "MyPlugin"
 */
interface WebFMyPlugin {
  /**
   * Perform an asynchronous operation.
   *
   * @param input Input string to process.
   * @returns Promise with processed result.
   */
  myAsyncMethod(input: string): Promise<string>;

  /**
   * Perform a synchronous operation.
   *
   * @param input Input string to process.
   * @returns Processed result.
   */
  mySyncMethod(input: string): string;

  /**
   * Perform a complex operation with structured options.
   *
   * @param options Configuration options.
   * @returns Promise with operation result.
   */
  complexMethod(options: MyOptionsType): Promise<MyResultType>;
}

TypeScript Guidelines:

  • Interface name should match WebF{ModuleName}
  • Use JSDoc comments for documentation
  • Use ? for optional parameters
  • Use Promise<T> for async methods
  • Define separate interfaces for complex types
  • Use string for success/failure flags (for backward compatibility)

Step 4: Create Main Export File

lib/webf_my_plugin.dart:

/// WebF MyPlugin module for [describe functionality]
///
/// This module provides functionality to:
/// - Feature 1
/// - Feature 2
/// - Feature 3
///
/// Example usage:
/// ```dart
/// // Register module globally (in main function)
/// WebF.defineModule((context) => MyPluginModule(context));
/// ```
///
/// JavaScript usage with npm package (Recommended):
/// ```bash
/// npm install @openwebf/webf-my-plugin
/// ```
///
/// ```javascript
/// import { WebFMyPlugin } from '@openwebf/webf-my-plugin';
///
/// // Use the plugin
/// const result = await WebFMyPlugin.myAsyncMethod('input');
/// console.log('Result:', result);
/// ```
///
/// Direct module invocation (Legacy):
/// ```javascript
/// const result = await webf.invokeModuleAsync('MyPlugin', 'myAsyncMethod', 'input');
/// ```
libr

---

*Content truncated.*

When not to use it

  • Developing UI visual components (use Native UI instead)
  • Simple web-based features that do not require platform access

Prerequisites

Flutter SDKWebF framework

Limitations

  • Requires knowledge of both Flutter and TypeScript
  • Performance overhead for high-frequency data crossing the bridge

How it compares

It creates a bridge that allows non-web-native features to be consumed directly as JS modules, distinct from building UI widgets.

Compared to similar skills

webf-native-plugin-dev side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
webf-native-plugin-dev (this skill)27moReviewAdvanced
cometchat-calls01moReviewIntermediate
webf-native-plugins17moReviewAdvanced
pangle-ad-integration02moNo flagsBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

More by openwebf

View all by openwebf

webf-infinite-scrolling

openwebf

Create high-performance infinite scrolling lists with pull-to-refresh and load-more capabilities using WebFListView. Use when building feed-style UIs, product catalogs, chat messages, or any scrollable list that needs optimal performance with large datasets.

26

webf-api-compatibility

openwebf

Check Web API and CSS feature compatibility in WebF - determine what JavaScript APIs, DOM methods, CSS properties, and layout modes are supported. Use when planning features, debugging why APIs don't work, or finding alternatives for unsupported features like IndexedDB, WebGL, float layout, or CSS Grid.

16

webf-async-rendering

openwebf

Understand and work with WebF's async rendering model - handle onscreen/offscreen events and element measurements correctly. Use when getBoundingClientRect returns zeros, computed styles are incorrect, measurements fail, or elements don't layout as expected.

13

webf-native-plugins

openwebf

Install WebF native plugins to access platform capabilities like sharing, payment, camera, geolocation, and more. Use when building features that require native device APIs beyond standard web APIs.

14

webf-native-ui

openwebf

Setup and use WebF's Cupertino UI library to build native iOS-style UIs with pre-built components instead of crafting everything with HTML/CSS. Use when building iOS apps, adding native UI components, or improving UI performance.

12

webf-native-ui-dev

openwebf

Develop custom native UI libraries based on Flutter widgets for WebF. Create reusable component libraries that wrap Flutter widgets as web-accessible custom elements. Use when building UI libraries, wrapping Flutter packages, or creating native component systems.

10

Search skills

Search the agent skills registry