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

@codedesignai/nextjs-live-edit-plugin

v1.0.10

Published

Next.js plugin for live editing React components with AST-powered source mapping

Readme

@codedesignai/nextjs-live-edit-plugin

A Next.js plugin for live editing React components with AST-powered source mapping. Enables precise, character-level updates to your source files directly from the browser.

This is the Next.js port of @codedesignai/vite-live-edit-plugin with 100% feature parity.

Features

  • 🎯 AST-Powered Source Mapping — Injects precise location data into JSX elements via a custom webpack loader
  • 📝 Text Content Editing — Edit text content directly from the browser
  • 🖼️ Image Source Editing — Update image sources with validation
  • Full Validation — Pre and post-update validation with rollback capability
  • 🔒 Security — Validates URLs and content before applying changes
  • Fast Refresh Integration — Changes trigger Next.js Fast Refresh automatically

Installation

npm install @codedesignai/nextjs-live-edit-plugin

Or from Git:

npm install git+https://github.com/codedesignapp/ai-companion-live-edit-plugin.git#nextjs

Setup

1. Update next.config.js

const { withLiveEdit } = require('@codedesignai/nextjs-live-edit-plugin');

module.exports = withLiveEdit({
  // your existing Next.js config options
});

Or with TypeScript/ESM (next.config.ts):

import { withLiveEdit } from '@codedesignai/nextjs-live-edit-plugin';

export default withLiveEdit({
  // your existing Next.js config options
});

Custom Source Directories

By default, the plugin processes .jsx and .tsx files in app/, components/, and src/. To customize:

module.exports = withLiveEdit(
  { /* next config */ },
  { sourceDirs: ['app', 'components', 'src', 'features'] }
);

2. Add the API Route

App Router (app/api/live-edit/route.js)

const { createLiveEditHandler } = require('@codedesignai/nextjs-live-edit-plugin/live-edit-handler');

const { POST, OPTIONS } = createLiveEditHandler();

module.exports = { POST, OPTIONS };

Or with TypeScript/ESM:

import { createLiveEditHandler } from '@codedesignai/nextjs-live-edit-plugin/live-edit-handler';

export const { POST, OPTIONS } = createLiveEditHandler();

Pages Router (pages/api/live-edit.js)

const { createPagesApiHandler } = require('@codedesignai/nextjs-live-edit-plugin/live-edit-handler');

module.exports = createPagesApiHandler();

How It Works

  1. Source Mapping (build time): The webpack loader parses .jsx/.tsx files with @babel/parser, walks the AST, and injects data-element-id and data-source-loc attributes into JSX elements that contain text or image sources.

  2. Live Editing (runtime): The /api/live-edit endpoint receives update requests from the browser, validates the location data against the actual source file (including AST-level verification), applies the text/image change, and lets Next.js Fast Refresh handle the reload.

API Endpoint

POST /api/live-edit
Content-Type: application/json

{
  "element": {
    "tagName": "P",
    "elementId": "Home-p-L5-0",
    "sourceLoc": {
      "file": "page.tsx",
      "start": 123,
      "end": 145,
      "text": "Original text",
      "type": "text-content"
    }
  },
  "content": "New text content"
}

Requirements

  • Node.js >= 18.0.0
  • Next.js >= 13.0.0
  • React (for JSX support)

Configuration

The plugin automatically:

  • Only runs in development mode
  • Only processes .jsx and .tsx files in configured source directories
  • Only adds the webpack loader for client-side builds (not server-side)
  • Injects source mapping data into JSX elements for browser interaction

No additional configuration is required beyond the two setup steps above.

Comparison with Vite Plugin

| Concept | Vite Plugin | Next.js Plugin | |---|---|---| | Source mapping | sourceMapperPlugin() (Vite transform hook) | Custom webpack loader | | Live edit API | enhancedLiveEditPlugin() (dev server middleware) | Next.js API route | | Hot reload | server.reloadModule() | Automatic Fast Refresh | | File filter | src/ directory | app/, components/, src/ (configurable) |

License

MIT