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-cli

v1.1.6

Published

CLI tool for easy GTM Kit setup - auto-detects your framework and installs everything you need.

Readme

@jwiedeman/gtm-kit-cli

CI Coverage npm version TypeScript License: MIT Node.js

Zero-config GTM Kit setup. Auto-detects your framework. Installs everything you need.

The CLI tool for GTM Kit - get up and running in under 60 seconds.


Quick Start

npx @jwiedeman/gtm-kit-cli init

That's it. The CLI will:

  1. Detect your framework (React, Vue, Next.js, Nuxt, etc.)
  2. Detect your package manager (npm, yarn, pnpm, bun)
  3. Install the right packages
  4. Generate setup code for your project
  5. Optionally configure Consent Mode v2

Commands

init - Interactive Setup

npx @jwiedeman/gtm-kit-cli init

Walks you through the complete setup with prompts for:

  • GTM container ID
  • Consent Mode v2 configuration
  • File locations

init <GTM-ID> - Quick Setup

npx @jwiedeman/gtm-kit-cli init GTM-XXXXXX

Skip the prompts if you already know your GTM ID.

detect - Framework Detection

npx @jwiedeman/gtm-kit-cli detect

Shows what framework and package manager the CLI detected.

validate <GTM-ID> - ID Validation

npx @jwiedeman/gtm-kit-cli validate GTM-XXXXXX

Validates a GTM container ID format.

generate <GTM-ID> - Code Generation

npx @jwiedeman/gtm-kit-cli generate GTM-XXXXXX

Generates setup code without installing packages.


Supported Frameworks

| Framework | Detection | Priority | | --------- | ----------------------- | -------- | | Nuxt 3 | nuxt.config.ts/js | Highest | | Next.js | next.config.ts/js/mjs | High | | Vue 3 | vue in dependencies | Medium | | React | react in dependencies | Low | | Vanilla | Default fallback | Lowest |

The CLI uses priority order because some projects have multiple frameworks (e.g., Next.js includes React).


Package Manager Detection

The CLI automatically detects your package manager:

| Package Manager | Detection | | --------------- | ---------------- | | pnpm | pnpm-lock.yaml | | yarn | yarn.lock | | bun | bun.lockb | | npm | Default fallback |


Generated Code Examples

React

// src/gtm.tsx (generated)
import { GtmProvider } from '@jwiedeman/gtm-kit-react';

export function GtmWrapper({ children }) {
  return <GtmProvider config={{ containers: 'GTM-XXXXXX' }}>{children}</GtmProvider>;
}

Vue

// src/plugins/gtm.ts (generated)
import { GtmPlugin } from '@jwiedeman/gtm-kit-vue';

export function setupGtm(app) {
  app.use(GtmPlugin, { containers: 'GTM-XXXXXX' });
}

Next.js

// app/layout.tsx additions (generated)
import { GtmHeadScript, GtmNoScript } from '@jwiedeman/gtm-kit-next';

// Add to <head>: <GtmHeadScript containers="GTM-XXXXXX" />
// Add to <body>: <GtmNoScript containers="GTM-XXXXXX" />

Nuxt

// plugins/gtm.client.ts (generated)
import { GtmPlugin } from '@jwiedeman/gtm-kit-nuxt';

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(GtmPlugin, { containers: 'GTM-XXXXXX' });
});

Options

--dry-run

Preview what would happen without making changes.

npx @jwiedeman/gtm-kit-cli init --dry-run

--typescript / --no-typescript

Force TypeScript or JavaScript output.

npx @jwiedeman/gtm-kit-cli init --typescript
npx @jwiedeman/gtm-kit-cli init --no-typescript

--consent

Include Consent Mode v2 configuration.

npx @jwiedeman/gtm-kit-cli init --consent

Troubleshooting

"Framework not detected correctly"

The CLI checks for config files and dependencies. If detection is wrong:

# Check what was detected
npx @jwiedeman/gtm-kit-cli detect

# You can manually install the right packages
npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-react

"Permission denied"

On Unix systems, you may need to use npx or install globally:

# Use npx (recommended)
npx @jwiedeman/gtm-kit-cli init

# Or install globally
npm install -g @jwiedeman/gtm-kit-cli
gtm-kit init

"Package installation failed"

If automatic installation fails:

  1. Check your internet connection
  2. Try installing manually:
    npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-react
  3. Check for npm registry issues

Programmatic Usage

import { detectFramework, detectPackageManager, validateGtmId, generateCode } from '@jwiedeman/gtm-kit-cli';

// Detect framework
const framework = await detectFramework('./my-project');
console.log(framework); // { name: 'react', confidence: 90 }

// Detect package manager
const pm = await detectPackageManager('./my-project');
console.log(pm); // 'pnpm'

// Validate GTM ID
const isValid = validateGtmId('GTM-XXXXXX');
console.log(isValid); // true

// Generate code
const code = generateCode({
  framework: 'react',
  gtmId: 'GTM-XXXXXX',
  typescript: true,
  consent: true
});

Requirements

  • Node.js 18+
  • npm, yarn, pnpm, or bun

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