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

@petecoop/livewire-bridge

v0.0.1

Published

Vite-powered client components and scripts for Livewire.

Readme

livewire-bridge

import inside Livewire scripts. Provides a react wrapper and useWire() hook for Livewire state.

Installation

composer require petecoop/livewire-bridge
npm install @petecoop/livewire-bridge

React support is optional. Install its runtime and Vite plugin when using bridge:react:

npm install react react-dom
npm install --save-dev @vitejs/plugin-react

Vite configuration

import laravel, { refreshPaths } from "laravel-vite-plugin";
import livewireBridge, { exceptLivewire } from "@petecoop/livewire-bridge";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [
    laravel({
      input: ["resources/css/app.css", "resources/js/app.js"],
      refresh: exceptLivewire(refreshPaths),
    }),
    react(),
    livewireBridge(),
  ],
});

exceptLivewire() removes Livewire's component directories from Laravel's refresh paths so the Livewire plugin can manage their updates. The exported livewirePaths array contains the paths that it excludes and that the plugin scans by default, matching an unmodified Livewire 4 application:

  • resources/views/components
  • resources/views/livewire
  • resources/views/layouts
  • resources/views/pages

Use the single paths option when the application has different component locations:

livewireBridge({ paths: ["resources/views/components"] });

Publish config/livewire-bridge.php and set the corresponding absolute PHP paths when they differ from Livewire's configured component locations and namespaces.

Import

Use bridge to mark a <script> block for Vite processing. $wire and $js are available in the script:

<script lang="ts" bridge>
    import { format } from "some-package";

    $js("formattedCount", () => format($wire.count));
</script>

React

Use bridge:react to mark a <script> block for Vite processing and React component export. Use a wire:ref target to mount the component. The useWire() hook provides a reactive $wire proxy for reading and writing Livewire state:

<div wire:ref="app" wire:ignore></div>

<script lang="tsx" bridge:react="app">
    import { useWire } from "@petecoop/livewire-bridge/react";

    export default function Counter() {
        const $wire = useWire();

        return <button onClick={() => $wire.count++}>{$wire.count}</button>;
    }
</script>

The script must default-export a React component. React scripts use a stable root adapter and a separately refreshable component module, so compatible local state survives React Fast Refresh without reloading the Livewire component.

useWire() hook

useWire() returns a writable $wire proxy and tracks the reactive paths read during the committed React render.

Property writes, $set, and Livewire action calls continue to pass through the same $wire proxy. A useWire() call used only inside an event handler records no render dependencies.

The hook updates for Alpine mutations, React proxy writes, and server responses without creating $watch subscriptions.

Multi-file components

The bridge automatically handles a script next to a Livewire multi-file component when its filename matches the component and one of these conditions is true:

  • .js files use the bridge when they contain an import; plain JavaScript stays on Livewire's native script path.
  • .jsx, .ts, and .tsx files run as general bridge scripts with $wire and $js in scope.
  • .react.jsx and .react.tsx files use the React adapter. They must export a wireRef string naming the mount target and default-export the component.
resources/views/pages/⚡counter/
├── counter.php
├── counter.blade.php
└── counter.react.tsx
<div wire:ref="counter" wire:ignore></div>
import { useWire } from "@petecoop/livewire-bridge/react";

export const wireRef = "counter";

export default function Counter() {
  const $wire = useWire<{ count: number }>();

  return <button onClick={() => $wire.count++}>{$wire.count}</button>;
}