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

@mvtlab/nextjs-orchestrator

v0.1.3

Published

Next.js SDK to integrate the MVT Lab CDN engine with optional anti-flicker support.

Readme

@mvtlab/nextjs-orchestrator

npm version npm downloads License

React component for integrating MVTLab.io CDN engine into Next.js applications with optional anti-flicker support.


Installation

npm install @mvtlab/nextjs-orchestrator
# or
yarn add @mvtlab/nextjs-orchestrator

Requirements: Next.js >= 13.0.0, React >= 18.0.0


Quick Start

Wrap your app at the root level. The component must be in a client component file ('use client';).

App Router

// app/layout.tsx
'use client';

import { MVTOrchestrator } from '@mvtlab/nextjs-orchestrator';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <MVTOrchestrator orchestratorKey="YOUR_PROJECT_KEY">
          {children}
        </MVTOrchestrator>
      </body>
    </html>
  );
}

Pages Router

// pages/_app.tsx
'use client';

import { MVTOrchestrator } from '@mvtlab/nextjs-orchestrator';

export default function MyApp({ Component, pageProps }) {
  return (
    <MVTOrchestrator orchestratorKey="YOUR_PROJECT_KEY">
      <Component {...pageProps} />
    </MVTOrchestrator>
  );
}

Why 'use client'? The component injects scripts and styles, accesses window/document, and defines window.rmfk—all browser-only operations that can't run in server components.


API

Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | orchestratorKey | string | ✅ | - | MVTLab.io project key (passed as data-project-key) | | children | ReactNode | ✅ | - | App content to wrap | | antiFlickerEnabled | boolean | ❌ | true | Inject temporary body{opacity:0} style until engine ready | | antiFlickerTimeoutMs | number | ❌ | 3000 | Fallback timeout to remove anti-flicker style |

TypeScript

import type { MVTOrchestratorProps } from '@mvtlab/nextjs-orchestrator';

Usage Examples

Basic

<MVTOrchestrator orchestratorKey="abc123xyz">
  <YourApp />
</MVTOrchestrator>

Disable Anti-Flicker

<MVTOrchestrator
  orchestratorKey="abc123xyz"
  antiFlickerEnabled={false}
>
  <YourApp />
</MVTOrchestrator>

Custom Timeout

<MVTOrchestrator
  orchestratorKey="abc123xyz"
  antiFlickerTimeoutMs={5000}
>
  <YourApp />
</MVTOrchestrator>

Environment Variables

// .env.local
NEXT_PUBLIC_MVT_PROJECT_KEY=your_key_here
<MVTOrchestrator
  orchestratorKey={process.env.NEXT_PUBLIC_MVT_PROJECT_KEY!}
>
  {children}
</MVTOrchestrator>

How It Works

Script Injection

On mount (client-side only via useEffect):

  1. Checks for existing script with id="mvt-engine-script"
  2. If missing, creates <script> with:
    • src="https://staging-svc.mvtlab.io/scripts/engine.js"
    • data-project-key={orchestratorKey}
    • data-mvt="engine"
    • async={true}
  3. Appends to <head>

This ensures one script per page, even on re-renders.

Anti-Flicker

When antiFlickerEnabled={true}:

  1. Injects <style id="abhide">body{opacity:0}</style> into <head>
  2. Defines window.rmfk() to remove the style element
  3. Engine calls window.rmfk() when ready
  4. Safety timeout (default 3000ms) calls window.rmfk() as fallback

The id="abhide" matches the original HTML snippet's style identifier. The function name rmfk stands for "remove flicker"—a callback the engine uses to signal readiness.

Project Key Validation

  • Stores orchestratorKey in window.__mvtOrchestratorKey on mount
  • If a different key is detected, logs error and skips script injection
  • Enforces one key per website (wrap once at root)

Troubleshooting

Script not loading?

  • Ensure 'use client'; is present
  • Verify orchestratorKey is correct
  • Check browser console for errors

Anti-flicker not working?

  • Confirm antiFlickerEnabled={true}
  • Check if window.rmfk() is called (inspect console)
  • Increase antiFlickerTimeoutMs if engine loads slowly

Multiple scripts?

  • Use MVTOrchestrator only once at root
  • Don't use different keys on the same page

SSR errors?

  • All DOM access is in useEffect (browser-only)
  • Ensure 'use client'; is at the top of the file

FAQ

Is this SSR-safe?
Yes. DOM operations run in useEffect, which only executes in the browser. Server renders {children}; script injection is client-only.

Can I use multiple project keys?
No. Use one orchestratorKey at the root for the entire website. Different keys on the same page will log an error.

What if the engine fails to load?
The timeout (default 3000ms) removes the anti-flicker style, so the page becomes visible. Engine features won't be available.

TypeScript support?
Full type definitions included. Import MVTOrchestratorProps for type checking.

Browser support?
Modern browsers with ES2019+, React 18+, and standard DOM APIs.


License

Licensed under MVTLab.io. Copyright © MVTLab.io. All rights reserved.

See LICENSE for details.


Support


This package wraps the standard MVTLab.io HTML integration snippet into a React component. The original snippet uses an IIFE pattern with document, window, and a timeout—this SDK translates that into React hooks and TypeScript types.