PhoenixKit.Install.JsIntegration (phoenix_kit v1.7.38)

Copy Markdown View Source

Handles automatic JavaScript integration for PhoenixKit installation.

This module provides functionality to:

  • Add PhoenixKit JS import for hooks and interactive features
  • Update liveSocket hooks configuration automatically
  • Ensure idempotent operations (safe to run multiple times)
  • Provide fallback instructions if automatic integration fails

Import Strategy

PhoenixKit JavaScript is imported directly from the deps directory, similar to CSS. This means updates to PhoenixKit automatically include updated JavaScript without needing to run phoenix_kit.update.

The import path is relative to your app.js location:

  • assets/js/app.jsimport "../../deps/phoenix_kit/priv/static/assets/phoenix_kit.js"
  • priv/static/assets/app.jsimport "../../../deps/phoenix_kit/priv/static/assets/phoenix_kit.js"

Summary

Functions

Automatically integrates PhoenixKit JavaScript with the parent app's app.js.

Checks what PhoenixKit JS integration already exists in content. Returns a map with detected integrations.

Functions

add_automatic_js_integration(igniter)

Automatically integrates PhoenixKit JavaScript with the parent app's app.js.

Parameters

  • igniter - The igniter context

Returns

Updated igniter with JS integration applied automatically.

add_smart_js_integration(source, import_statement \\ nil)

check_existing_integration(content)

Checks what PhoenixKit JS integration already exists in content. Returns a map with detected integrations.