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

next-live2d

v2.0.5

Published

A simple React component to embed Live2D models in Next.js projects with customizable options

Readme

A simple React component to embed Live2D models (via live2d-widget) in Next.js projects.

npm License: MIT GitHub Repo stars npm

Live2D Widget Preview

📢 Latest Update

v2.0.2 - GitHub Username Migration

  • Updated default baseUrl host from the old GitHub username to 2hjaito.
  • Updated repository links and badges to the new GitHub profile.
  • Kept full compatibility for existing model paths ending with /model.json.

Full history:

✨ Features

  • 🧠 Auto-load Live2D Widget
  • ⚙️ Zero-config usage with App Router
  • 🎒 Comes with 35+ built-in models
  • ✅ SSR-safe using dynamic(() => import(...), { ssr: false })
  • 🎲 Random model selection
  • 🎨 Full customization (position, size, opacity, etc.)
  • 📦 Custom base URL support (self-host models)
  • 🔄 Loading state & error handling
  • 💪 TypeScript support with exported types
  • ⚡ React 18 & 19 compatible

🚀 Installation

npm install next-live2d

🧩 Usage in Next.js (app/layout.tsx)

'use client'

import { Live2DWidget } from 'next-live2d'

import { ReactNode } from 'react'
import './globals.css'

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html lang="en">
      <body>
        <main>{children}</main>
        <Live2DWidget modelName="mai" />
      </body>
    </html>
  )
}

🔧 Advanced Usage

🛡️ Next.js Stability Guide

To minimize runtime issues in production projects:

  1. Render Live2DWidget only in Client Components.
  2. Avoid rendering the widget from Server Components directly.
  3. Keep one widget instance per page/layout to avoid competing initializations.
  4. Prefer stable modelName values across frequent rerenders.
  5. For custom model hosting, ensure model.json and textures are accessible with correct CORS headers.

Recommended pattern for App Router:

'use client'

import { Live2DWidget } from 'next-live2d'

export default function Live2DClientWidget() {
  return <Live2DWidget modelName="histoire" />
}

Basic Customization

<Live2DWidget
  modelName="senko"
  position="left"
  width={200}
  height={350}
  opacity={0.9}
  hoverOpacity={0.3}
/>

Random Model

<Live2DWidget random />

Custom Base URL (Self-host models)

<Live2DWidget
  modelName="my-model"
  baseUrl="https://my-cdn.com/live2d-models"
/>

With Loading State & Callbacks

<Live2DWidget
  modelName="histoire"
  fallback={<div>Loading Live2D...</div>}
  onLoad={() => console.log('Model loaded!')}
  onError={(err) => console.error('Failed:', err)}
  onClick={() => alert('You clicked the model!')}
/>

Tailwind CSS

<Live2DWidget
  modelName="senko"
  className="bottom-0 right-0 fixed z-50 opacity-80"
  style={{ width: 200, height: 300 }}
/>

📋 Props Reference

| Prop | Type | Default | Description | |------|------|---------|-------------| | modelName | string | 'histoire' | Name of the model folder (must include model.json) | | baseUrl | string | GitHub raw URL | Custom base URL to load models from | | position | 'left' \| 'right' | 'right' | Widget position on screen | | width | number | 180 | Widget width in pixels | | height | number | 300 | Widget height in pixels | | opacity | number | 0.8 | Default opacity (0-1) | | hoverOpacity | number | 0.2 | Opacity when hovering (0-1) | | showOnMobile | boolean | true | Show widget on mobile devices | | random | boolean | false | Pick a random built-in model | | className | string | - | Custom CSS/Tailwind classes | | style | CSSProperties | - | Inline styles | | fallback | ReactNode | - | Component to show while loading | | onLoad | () => void | - | Callback when model loads | | onError | (error) => void | - | Callback on load error | | onClick | () => void | - | Callback when widget is clicked |

🧭 Versioning

  • This project follows semantic versioning.
  • Patch releases focus on stability and compatibility fixes.
  • Minor releases add non-breaking features.
  • Major releases may include behavior changes or migration notes.

🔤 TypeScript Support

import { 
  Live2DWidget,
  Live2DWidgetProps,
  ModelName,
  BUILT_IN_MODELS,
  getRandomModel 
} from 'next-live2d';

// Get a random model name
const model: ModelName = getRandomModel();

// Access all built-in model names
console.log(BUILT_IN_MODELS); // ['histoire', 'bilibili-22', ...]

🧠 Tips

The Live2D widget is rendered into a #live2d-widget DOM element, positioned as fixed by default.

If you pass className or style, they will override the default style.

📁 Model Path

By default, the widget looks for:

📦 Available Built-in Models

| Model Name | Preview (coming soon) | Usage | |----------------------|-------------------------------|--------------------------------------| | histoire | | <Live2DWidget modelName="histoire" /> | | bilibili-22 | | <Live2DWidget modelName="bilibili-22" /> | | bilibili-33 | | <Live2DWidget modelName="bilibili-33" /> | | cat-black | | <Live2DWidget modelName="cat-black" /> | | cat-white | | <Live2DWidget modelName="cat-white" /> | | chino | | <Live2DWidget modelName="chino" /> | | date | | <Live2DWidget modelName="date" /> | | hallo | | <Live2DWidget modelName="hallo" /> | | haruto | | <Live2DWidget modelName="haruto" /> | | hibiki | | <Live2DWidget modelName="hibiki" /> | | HK416-1-normal | | <Live2DWidget modelName="HK416-1-normal" /> | | HK416-2-destroy | | <Live2DWidget modelName="HK416-2-destroy" /> | | HK416-2-normal | | <Live2DWidget modelName="HK416-2-normal" /> | | Kar98k-normal | | <Live2DWidget modelName="Kar98k-normal" /> | | kobayaxi | | <Live2DWidget modelName="kobayaxi" /> | | koharu | | <Live2DWidget modelName="koharu" /> | | kp31 | | <Live2DWidget modelName="kp31" /> | | live_uu | | <Live2DWidget modelName="live_uu" /> | | mai | | <Live2DWidget modelName="mai" /> | | murakumo | | <Live2DWidget modelName="murakumo" /> | | Pio | | <Live2DWidget modelName="Pio" /> | | platelet | | <Live2DWidget modelName="platelet" /> | | platelet_2 | | <Live2DWidget modelName="platelet_2" /> | | potion-Maker-Pio | | <Live2DWidget modelName="potion-Maker-Pio" /> | | rem | | <Live2DWidget modelName="rem" /> | | rem_2 | | <Live2DWidget modelName="rem_2" /> | | shizuku | | <Live2DWidget modelName="shizuku" /> | | shizuku_48 | | <Live2DWidget modelName="shizuku_48" /> | | shizuku_pajama | | <Live2DWidget modelName="shizuku_pajama" /> | | terisa | | <Live2DWidget modelName="terisa" /> | | tia | | <Live2DWidget modelName="tia" /> | | umaru | | <Live2DWidget modelName="umaru" /> | | uni | | <Live2DWidget modelName="uni" /> | | wed_16 | | <Live2DWidget modelName="wed_16" /> | | xisitina | | <Live2DWidget modelName="xisitina" /> | | z16 | | <Live2DWidget modelName="z16" /> | | Senko_Normals | | <Live2DWidget modelName="Senko_Normals" /> |

🧑‍💻 Author

Trần Hữu Đang Website: https://dangth.dev

📝 License MIT