@molecule/app-analytics-svelte

Feature · analytics · App (browser) · v1.1.2 · Apache-2.0

Svelte bindings for @molecule/app-analytics (route listener)

npm install @molecule/app-analytics-svelte

npm · Source on GitHub

How it works

@molecule/app-analytics-svelte is a ready-made analytics feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { setMoleculeContext } from '@molecule/app-svelte'
  import { AnalyticsRouteListener } from '@molecule/app-analytics-svelte'
  import { Home } from './Home.svelte'

  let { router } = $props()
  setMoleculeContext({ router })
</script>

<AnalyticsRouteListener />
<Home />

Works with: @molecule/app-analytics, @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte bindings for @molecule/app-analytics.

Provides ready-made Svelte components that consume the wired analytics bond. Currently exports AnalyticsRouteListener, a render-free component that fires a page event on every client-side route change.

Mount AnalyticsRouteListener once inside the molecule context's router scope — it follows useLocation() and forwards each pathname / search change to the wired analytics bond's page().

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { setMoleculeContext } from '@molecule/app-svelte'
  import { AnalyticsRouteListener } from '@molecule/app-analytics-svelte'
  import { Home } from './Home.svelte'

  let { router } = $props()
  setMoleculeContext({ router })
</script>

<AnalyticsRouteListener />
<Home />

Type

feature

Installation

npm install @molecule/app-analytics-svelte @molecule/app-analytics @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Constants

AnalyticsRouteListener

const AnalyticsRouteListener: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-analytics ^1.0.1
  • @molecule/app-svelte ^3.11.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-analytics
  • @molecule/app-svelte
  • @molecule/app-ui
  • @molecule/app-ui-svelte
  • svelte