jaspr-js-interop

Integrate Jaspr web apps with JavaScript libraries using universal_web interop.

803|85|Updated Nov 18, 2023
One-click install
npx skills add https://github.com/rodydavis/signals.dart --skill jaspr-js-interop
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jaspr-js-interop
Source: https://github.com/rodydavis/signals.dart/tree/main/.agents/skills/jaspr-js-interop
Command: npx skills add https://github.com/rodydavis/signals.dart --skill jaspr-js-interop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents Jaspr applications from crashing or behaving inconsistently when you need to call JavaScript libraries or browser-native APIs during rendering.

Core Features & Use Cases

  • Server-safe JS interop: Uses universal_web stubs and enforces web-only execution guards to avoid server/pre-render failures.
  • JS library bindings: Binds to global JS functions/objects using @JS() and extension types for typed interaction.
  • Config object bridging: Uses @anonymous extension types to send and receive plain JavaScript object literals safely.

Quick Start

Use the jaspr-js-interop skill to wrap a third-party browser analytics library by importing the correct universal_web interop module and calling the JS entrypoints only inside a kIsWeb guard.

Frequently Asked Questions about jaspr-js-interop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use JavaScript interop in Jaspr without breaking server rendering?▼

To use JavaScript interop in Jaspr without breaking server rendering, import package:universal_web/js_interop.dart for server or static modes, and enforce web-only execution using kIsWeb guards to prevent pre-render failures.

Why does my Jaspr app crash when calling browser APIs during rendering?▼

Your Jaspr app crashes during rendering because direct JavaScript calls fail outside the browser. You must guard browser-native API execution with kIsWeb checks and use universal_web stubs to safely bridge JS primitives.

Can I bind to global JavaScript functions and pass configuration objects in Jaspr?▼

Yes, you can bind to global JavaScript functions and pass configuration objects in Jaspr by using @JS() and extension types for typed interaction, along with @anonymous extension types to safely send plain JavaScript object literals.

When should I use dart:js_interop versus universal_web in a Jaspr application?▼

Use dart:js_interop only on the client side, whereas you should prefer package:universal_web/web.dart for standard browser APIs and universal_web/js_interop.dart when server or static rendering modes are active.

What is the best way to integrate a third-party JavaScript library with a Jaspr web app?▼

The best way to integrate a third-party JavaScript library with a Jaspr web app is to wrap the library using universal_web interop modules and invoke its JavaScript entrypoints exclusively inside a kIsWeb guard.