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

@bagisto-native/react

v1.0.0

Published

react specific wrapper for @bagisto-native/core

Downloads

74

Readme

@bagisto-native/react

@bagisto-native/react provides React wrappers for the Web Components included in @bagisto-native/core, making it easy to integrate Bagisto Native functionality into React.js and Next.js applications.

It is designed to work smoothly with Open Source Headless eCommerce and any React.js or Next.js setup, making it easy to connect a headless storefront with native mobile apps.

This module is intended to be used together with @bagisto-native/core.

Note: To create Bagisto Headless Commerce, use the following command:

npx -y @bagisto-headless/create your-storefront

📦 Installation

Install the module via npm:

npm install @bagisto-native/react

Note: Ensure that @bagisto-native/core is also installed and the bundle.js is included in your project.

🌐 Components

@bagisto-native/react provides React wrappers for the following Web Components:

| Component | Description | | -------------------- | ----------------------------------------------------------------- | | DynamicButton | Handles native buttons for cart, share, barcode, and image search | | HotwireToast | Trigger native toast messages | | HotwireSearch | Trigger native search events | | HotwireLocation | Auto-fill checkout address using native location | | HotwireHistorySync | Send current page URL to native apps | | HotwireThemeMode | Send current theme mode (light/dark) |

All components should be used inside client components in Next.js ('use client') since they interact with the browser.

⚡ Usage Examples

Hotwire Toast

'use client';
import dynamic from 'next/dynamic';

const HotwireToast = dynamic(
  () => import('@bagisto-native/react').then(mod => mod.HotwireToast),
  { ssr: false }
);

export default function AppToast() {
  return <HotwireToast />;
}

Trigger a toast from @bagisto-native/core:

import { triggerHotwireNativeToast } from '@bagisto-native/core';

triggerHotwireNativeToast('Hello World!');

Hotwire History Sync

'use client';
import dynamic from 'next/dynamic';

const HotwireHistorySync = dynamic(
  () => import('@bagisto-native/react').then(mod => mod.HotwireHistorySync),
  { ssr: false }
);

export default function AppHistorySync() {
  return <HotwireHistorySync />;
}

Trigger history sync from @bagisto-native/core:

import { useEffect } from 'react';
import { usePathname, useSearchParams } from 'next/navigation';
import { triggerHistorySyncEvent } from '@bagisto-native/core';

export default function HistorySync() {
  const pathname = usePathname();
  const searchParams = useSearchParams();

  useEffect(() => {
    const url = new URL(`${window.location.origin}${pathname}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`);
    triggerHistorySyncEvent(url);
  }, [pathname, searchParams]);

  return null;
}

Hotwire Theme Mode

'use client';
import dynamic from 'next/dynamic';

const HotwireThemeMode = dynamic(
  () => import('@bagisto-native/react').then(mod => mod.HotwireThemeMode),
  { ssr: false }
);

export default function AppThemeMode() {
  return <HotwireThemeMode />;
}

Send theme mode:

import { triggerThemeModeEvent } from '@bagisto-native/core';

triggerThemeModeEvent('light'); // 'light' or 'dark'

Hotwire Search

'use client';
import dynamic from 'next/dynamic';

const HotwireSearch = dynamic(
  () => import('@bagisto-native/react').then(mod => mod.HotwireSearch),
  { ssr: false }
);

export default function AppSearch() {
  return <HotwireSearch />;
}

Listen to search events:

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';

export default function TurboSearchRouterBridge() {
  const router = useRouter();

  useEffect(() => {
    const handleTurboSearch = (e: Event) => {
      const customEvent = e as CustomEvent<{ query: string }>;
      const query = customEvent.detail.query;
      router.push(`/search?q=${encodeURIComponent(query)}`);
    };

    window.addEventListener('turbo:next-search', handleTurboSearch);

    return () => window.removeEventListener('turbo:next-search', handleTurboSearch);
  }, [router]);

  return null;
}

Hotwire Location

'use client';
import dynamic from 'next/dynamic';

const HotwireLocation = dynamic(
  () => import('@bagisto-native/react').then(mod => mod.HotwireLocation),
  { ssr: false }
);

export default function AppLocation(props: { fieldNames: { address: string[]; city: string[]; postCode: string[] } }) {
  return (
    <HotwireLocation fieldNames={props.fieldNames} style={{ display: 'none' }}>
      Hotwire Location
    </HotwireLocation>
  );
}

Dynamic Button

'use client';
import dynamic from 'next/dynamic';

const DynamicButton = dynamic(
  () => import('@bagisto-native/react').then(mod => mod.DynamicButton),
  { ssr: false }
);

export default function AppDynamicButton(props: { dataPageType?: string }) {
  return (
    <>
      <DynamicButton pageType={props.dataPageType || 'home'} style={{ display: 'none' }} />
      <DynamicButton cartCountEvent={true} style={{ display: 'none' }} />
    </>
  );
}

Use pageType='home' on homepage, pageType='product' on product pages.

📋 Requirements

  • Node.js >= 18
  • React >= 18 / Next.js >= 15
  • @bagisto-native/core must be installed and bundle.js included

🆘 Support

Open an issue or discussion in the repository if you need help.

📄 License

MIT License