npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jwiedeman/gtm-kit-solid

v1.1.6

Published

SolidJS primitives and context for GTM Kit - Google Tag Manager integration with signals.

Readme

@jwiedeman/gtm-kit-solid

CI Coverage npm version Bundle Size TypeScript License: MIT SolidJS

SolidJS primitives and context for Google Tag Manager. Fine-grained reactivity.

The SolidJS adapter for GTM Kit - provides context and hooks for idiomatic Solid integration.


Installation

npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-solid
yarn add @jwiedeman/gtm-kit @jwiedeman/gtm-kit-solid
pnpm add @jwiedeman/gtm-kit @jwiedeman/gtm-kit-solid

Quick Start

Step 1: Wrap Your App

// App.tsx
import { GtmProvider } from '@jwiedeman/gtm-kit-solid';

function App() {
  return (
    <GtmProvider containers="GTM-XXXXXX">
      <MyApp />
    </GtmProvider>
  );
}

Step 2: Push Events

import { useGtmPush } from '@jwiedeman/gtm-kit-solid';

function BuyButton() {
  const push = useGtmPush();

  return <button onClick={() => push({ event: 'purchase', value: 49.99 })}>Buy Now</button>;
}

That's it! GTM is now running.


Features

| Feature | Description | | ------------------- | ----------------------------------- | | SolidJS Native | Built for Solid's reactivity system | | Fine-Grained | Only updates what needs to update | | Context-Based | Uses Solid's context API | | TypeScript | Full type definitions included | | Consent Mode v2 | Built-in GDPR compliance | | SSR Compatible | Safe for SolidStart SSR |


Available Hooks

useGtm()

Get the full GTM context.

import { useGtm } from '@jwiedeman/gtm-kit-solid';

function MyComponent() {
  const { push, client, updateConsent, initialized } = useGtm();

  return (
    <div>
      <p>GTM Initialized: {initialized ? 'Yes' : 'No'}</p>
      <button onClick={() => push({ event: 'click' })}>Track</button>
    </div>
  );
}

useGtmPush()

Get just the push function.

import { useGtmPush } from '@jwiedeman/gtm-kit-solid';

function MyComponent() {
  const push = useGtmPush();

  return <button onClick={() => push({ event: 'purchase', value: 99 })}>Buy</button>;
}

useGtmConsent()

Access consent management functions.

import { useGtmConsent } from '@jwiedeman/gtm-kit-solid';

function CookieBanner() {
  const { updateConsent } = useGtmConsent();

  const acceptAll = () => {
    updateConsent({
      ad_storage: 'granted',
      analytics_storage: 'granted',
      ad_user_data: 'granted',
      ad_personalization: 'granted'
    });
  };

  return <button onClick={acceptAll}>Accept All</button>;
}

useGtmClient()

Get the raw GTM client instance.

import { useGtmClient } from '@jwiedeman/gtm-kit-solid';

function MyComponent() {
  const client = useGtmClient();

  return <div>Initialized: {client.isInitialized() ? 'Yes' : 'No'}</div>;
}

useGtmReady()

Get a function that resolves when GTM is loaded.

import { useGtmReady } from '@jwiedeman/gtm-kit-solid';
import { onMount } from 'solid-js';

function MyComponent() {
  const whenReady = useGtmReady();

  onMount(async () => {
    const states = await whenReady();
    console.log('GTM loaded:', states);
  });

  return <div>Loading...</div>;
}

Provider Options

<GtmProvider
  containers="GTM-XXXXXX"
  autoInit={true}
  dataLayerName="dataLayer"
  host="https://www.googletagmanager.com"
  scriptAttributes={{ nonce: '...' }}
  onBeforeInit={(client) => {
    // Set consent defaults here
  }}
  onAfterInit={(client) => {
    // Called after GTM initializes
  }}
>
  {children}
</GtmProvider>

SolidStart Integration

Basic Setup

// src/root.tsx
import { GtmProvider } from '@jwiedeman/gtm-kit-solid';

export default function Root() {
  return (
    <Html>
      <Head />
      <Body>
        <GtmProvider containers="GTM-XXXXXX">
          <Routes />
        </GtmProvider>
      </Body>
    </Html>
  );
}

Page Tracking with Router

import { useGtmPush } from '@jwiedeman/gtm-kit-solid';
import { useLocation } from '@solidjs/router';
import { createEffect } from 'solid-js';

function PageTracker() {
  const push = useGtmPush();
  const location = useLocation();

  createEffect(() => {
    push({
      event: 'page_view',
      page_path: location.pathname
    });
  });

  return null;
}

Consent Mode v2 (GDPR)

import { GtmProvider, useGtmConsent } from '@jwiedeman/gtm-kit-solid';
import { consentPresets } from '@jwiedeman/gtm-kit';

// In your root component
function App() {
  return (
    <GtmProvider
      containers="GTM-XXXXXX"
      onBeforeInit={(client) => {
        // Deny by default for EU users
        client.setConsentDefaults(consentPresets.eeaDefault, { region: ['EEA'] });
      }}
    >
      <MyApp />
      <CookieBanner />
    </GtmProvider>
  );
}

// Cookie banner component
function CookieBanner() {
  const { updateConsent } = useGtmConsent();

  return (
    <div class="cookie-banner">
      <p>We use cookies to improve your experience.</p>
      <button
        onClick={() =>
          updateConsent({
            ad_storage: 'granted',
            analytics_storage: 'granted',
            ad_user_data: 'granted',
            ad_personalization: 'granted'
          })
        }
      >
        Accept All
      </button>
      <button
        onClick={() =>
          updateConsent({
            ad_storage: 'denied',
            analytics_storage: 'denied',
            ad_user_data: 'denied',
            ad_personalization: 'denied'
          })
        }
      >
        Reject All
      </button>
    </div>
  );
}

Multiple Containers

<GtmProvider
  containers={[{ id: 'GTM-MAIN' }, { id: 'GTM-ADS', queryParams: { gtm_auth: 'abc', gtm_preview: 'env-1' } }]}
>
  {children}
</GtmProvider>

TypeScript

Full TypeScript support is included:

import type { GtmContextValue, GtmConsentApi } from '@jwiedeman/gtm-kit-solid';
import { useGtm, useGtmConsent } from '@jwiedeman/gtm-kit-solid';

function MyComponent() {
  const gtm: GtmContextValue = useGtm();
  const consent: GtmConsentApi = useGtmConsent();

  // Fully typed!
  gtm.push({ event: 'my_event', custom_param: 'value' });
}

Requirements

  • SolidJS 1.0+
  • @jwiedeman/gtm-kit (peer dependency)

Related Packages


Support

Have a question, found a bug, or need help?

Open an issue on GitHub — we're actively maintaining this project and respond quickly.


License

MIT