惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
罗磊的独立博客
V
Visual Studio Blog
爱范儿
爱范儿
H
Help Net Security
J
Java Code Geeks
I
InfoQ
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
S
SegmentFault 最新的问题
S
Securelist
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
博客园_首页
B
Blog
F
Fortinet All Blogs
AWS News Blog
AWS News Blog
V
Vulnerabilities – Threatpost
S
Secure Thoughts
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
Project Zero
Project Zero
Martin Fowler
Martin Fowler
C
Cybersecurity and Infrastructure Security Agency CISA
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I shipped a video player to npm — twice. What I learned about scoped CSS, "use client", and Nuxt modules.
Abdullah Al · 2026-05-09 · via DEV Community

A small, HLS-capable video player for React and Vue, with zero global CSS side-effects. Built in the open. Try it: https://video-player-playgraound.vercel.app/


The annoying gap

I needed an embeddable video player for a side project. Requirements were boring:

  • HLS streaming (.m3u8)
  • A clean play button overlay, optional close button, optional desktop/mobile aspect-ratio toggle
  • Fits the design system without fighting it
  • Works in Next.js App Router without a "ReactServerComponentsError" headache
  • Works in Nuxt 3 without manually wiring a plugin

I tried the popular options. Each was almost right.

  • react-player is mature but the API is geared toward "give me a URL and a giant control bar."
  • video.js is overkill for an embed and ships a chunk of theme CSS that fights Tailwind.
  • plyr, vidstack — beautiful, but either too heavy or too opinionated about styling.

The thing that kept biting me was CSS bleed. Every "drop-in" player I tried shipped global resets, theme tokens, or * selectors that quietly nudged my buttons by 1px or rewrote my form input borders. In a design system you've spent weeks tuning, that's a paper cut you don't want.

So I built one. Then, because half the consumers I had in mind were on Vue, I built it twice.

Both are at v1.0.2 today. Both are MIT. Both have the same prop surface, same UI, and ship under 4 KB gzipped of CSS + JS.

There's a live playground on Vercel where you can drop in a file or paste an HLS URL and try it end-to-end:

https://video-player-playgraound.vercel.app/

This post is the build-in-public version of how I got there. Three decisions ended up doing most of the work — the rest was just plumbing.


Decision 1: kill the global CSS

The first version of this player used Tailwind v4. I wrote the components, ran vite build --lib, and the resulting dist/style.css was 17 KB of:

:root, :host {
  --color-violet-700: ...;
  --font-sans: ui-sans-serif, system-ui, ...;
  /* ... */
}
*, ::before, ::after, ::backdrop {
  --tw-translate-x: 0;
  /* ... */
}

Enter fullscreen mode Exit fullscreen mode

That's the entire Tailwind preflight, baked in. Anyone who imported @glitchlab/react-video-player/style.css would get my theme tokens injected into :root and global resets on every element on their page.

For an internal app this is whatever. For a published library it's malpractice. So I rewrote the CSS by hand.

The full stylesheet now scopes everything under a single class:

.gvp-root {
  position: relative;
  overflow: hidden;
  border-radius: 1.5rem;
  background-color: rgb(23 23 23 / 0.3);
  /* ... */
}

.gvp-root *,
.gvp-root *::before,
.gvp-root *::after {
  box-sizing: border-box;
}

.gvp-play {
  background-color: rgb(91 33 182 / 0.5);
  /* ... */
}

Enter fullscreen mode Exit fullscreen mode

No :root, no * selectors at the document level. The component owns its subtree and nothing else. The CSS file dropped from 17 KB to 2.8 KB.

The bonus: consumers can now override with predictable specificity:

.gvp-root { border-radius: 8px; }
.gvp-play { background-color: rebeccapurple; }
.gvp-toggle-btn.is-active { color: deeppink; }

Enter fullscreen mode Exit fullscreen mode

That's the whole "design system" story. No @apply, no :where() tricks, no Tailwind dependency in the lib. Tailwind users still get to use Tailwind in their own app — the player just stops yelling at theirs.

Lesson: if you ship CSS in an npm package, treat it like API. Every selector you publish is a contract. :root { --color-foo: ...; } is a worse breaking change than removing a prop, because it breaks silently.


Decision 2: preserve "use client" through the build

The React package targets Next.js App Router. That means every file that uses hooks needs "use client"; at the top, otherwise Next refuses to render it from a server component.

The component source had it:

"use client";
import React, { useRef, useState } from "react";
// ...

Enter fullscreen mode Exit fullscreen mode

But here's the gotcha: rollup strips top-of-file directives during bundling unless you tell it not to. I ran vite build --lib, looked at dist/index.mjs, and the directive was gone. Importing the package from a Next App Router server component blew up with the classic "You're importing a component that needs useState" error.

The fix is a tiny rollup output plugin that re-prepends the directive after bundling:

// vite.config.ts (excerpt)
function preserveUseClient() {
  return {
    name: "preserve-use-client",
    renderChunk(code: string) {
      if (code.includes('"use client"') || code.includes("'use client'")) return null;
      return { code: `"use client";\n${code}`, map: null };
    },
  };
}

export default defineConfig({
  // ...
  build: {
    rollupOptions: {
      output: {
        plugins: [preserveUseClient()],
      },
    },
  },
});

Enter fullscreen mode Exit fullscreen mode

After this, both dist/index.mjs and dist/index.cjs start with "use client";. Consumers can import the package directly from a server component:

// app/page.tsx — server component
import { ReactVideoPlayer } from "@glitchlab/react-video-player";
import "@glitchlab/react-video-player/style.css";

export default function Page() {
  return <ReactVideoPlayer src="/videos/hero.m3u8" />;
}

Enter fullscreen mode Exit fullscreen mode

No client-component wrapper required. Just import and render.

Lesson: if your README claims "Next.js App Router compatible," verify the directive survives the bundler. Open dist/index.mjs after a build. If line 1 isn't "use client";, you're shipping a footgun.


Decision 3: ship a real Nuxt module

The Vue package was supposed to mirror the React one's "drop in and go" feel. For Nuxt, that meant a real module — not a "import this component manually in every page."

Nuxt's module system is a small library of helpers (@nuxt/kit) that lets you add plugins, components, and composables to a Nuxt app. The trick is that @nuxt/kit imports Node-only modules (giget, node:fs, etc.) — so if you naively re-export your Nuxt module from your main entry, the lib's vanilla Vue users get a bundle that tries to require node:fs in the browser.

The fix is to give Nuxt its own subpath export and never let it touch the main entry.

// package.json (excerpt)
{
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    },
    "./style.css": "./dist/style.css",
    "./nuxt": {
      "types": "./dist/nuxt-module.d.ts",
      "import": "./dist/nuxt-module.mjs",
      "require": "./dist/nuxt-module.cjs"
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

The vite config emits two entries:

build: {
  lib: {
    entry: {
      index: resolve(__dirname, "src/index.ts"),
      "nuxt-module": resolve(__dirname, "src/utils/nuxt-module.ts"),
    },
    formats: ["es", "cjs"],
  },
  rollupOptions: {
    external: ["vue", "hls.js", "@nuxt/kit", "#app", /^node:.*/],
  },
}

Enter fullscreen mode Exit fullscreen mode

The Nuxt module itself is mostly boilerplate:

// src/utils/nuxt-module.ts
import { addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";

export default defineNuxtModule({
  meta: {
    name: "@glitchlab/vue-video-player",
    configKey: "vueVideoPlayer",
    compatibility: { nuxt: ">=3.0.0" },
  },
  setup(_options, _nuxt) {
    const resolver = createResolver(import.meta.url);
    addPlugin(resolver.resolve("./nuxt-plugin"));
  },
});

Enter fullscreen mode Exit fullscreen mode

And the plugin auto-registers the component globally:

// src/utils/nuxt-plugin.ts
import { defineNuxtPlugin } from "#app";
import VideoPlayer from "../VideoPlayer.vue";

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.component("VueVideoPlayer", VideoPlayer);
});

Enter fullscreen mode Exit fullscreen mode

Now Nuxt 3 users get one-line integration:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ["@glitchlab/vue-video-player/nuxt"],
  css: ["@glitchlab/vue-video-player/style.css"],
});

Enter fullscreen mode Exit fullscreen mode

And the component is available globally — no import, just <VueVideoPlayer src="..." /> anywhere.

Lesson: subpath exports aren't optional for libraries with framework-specific entry points. Putting a Nuxt module behind ./nuxt means non-Nuxt consumers never load @nuxt/kit and its Node-only deps. Their browser bundle stays clean.


A bug that took an hour to find: Vue HLS first-mount race

I want to call this one out because it's a category of bug that's easy to ship and almost impossible to catch with smoke tests.

The Vue HLS player initialized like this:

<script setup lang="ts">
const videoEl = ref<HTMLVideoElement | null>(null);

watch(
  () => props.src,
  (src) => {
    if (src) initPlayer(src);
  },
  { immediate: true }   // 👈 the bug
);
</script>

Enter fullscreen mode Exit fullscreen mode

Looks fine. Tests passed. The deployed playground showed the player frame, the play button, the native controls bar — but the video never loaded. Click play, the play button vanished (so play() resolved), but no pixels.

The cause: watch(..., { immediate: true }) fires the callback during setup(), before the template renders. At that point videoEl.value is still null. initPlayer() early-returns, the watcher's already fired, and props.src doesn't change again — so HLS never attaches.

The React side wasn't affected because React effects always run after commit. The ref is bound by the time the effect fires.

The fix is two lines:

onMounted(() => {
  if (props.src) initPlayer(props.src);
});

watch(() => props.src, (src) => {
  if (src) initPlayer(src);
});  // no `immediate`

Enter fullscreen mode Exit fullscreen mode

Now the first init runs in onMounted (template ref is bound), and subsequent src changes are handled by the regular watcher.

Lesson: immediate: true and refs don't mix cleanly in Composition API. If your watcher needs a ref that's bound by the template, use onMounted for the first run and a non-immediate watch for updates.


The playground

I wanted a proof point that wasn't "trust the README." So I built a minimal Next.js app with three things:

  • A drag-and-drop file zone (uploads create blob URLs and feed them to the player)
  • A URL input with validation (paste any HTTP/HTTPS link, including .m3u8)
  • The player itself, configured to remount cleanly on source change via key={videoSrc}

It's deployed at https://video-player-playgraound.vercel.app/. You can:

  • Paste the test HLS stream https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8 and watch it play
  • Paste a CORS-permissive .mp4 URL and watch it play
  • Drop a local file and watch the blob URL feed the player

It runs on the actual published @glitchlab/react-video-player from npm. Every time I publish a new version, I bump the dep and redeploy — the playground exercises the real published bundle, not source.

The Vue package shares the same UX in the local playground at playground/vue/ in the monorepo. The deployed demo is React because that's what Vercel templates make easy; the Vue version is one pnpm dev:vue away if you clone the repo.


What's in v1.0.2

Both packages at v1.0.2 today:

  • Same prop surface across React and Vue. src, poster, showDeviceToggle, defaultDevice, hoverPlay, tooltipText, muted, loop, controls, frameMaxWidth, aspectRatio, hlsConfig, isHls. React adds onClose + children; Vue uses closable + @close event + default slot.
  • HLS via hls.js with automatic native fallback for Safari (no hls.js cost when MSE isn't needed).
  • Captions/subtitles passthrough. Pass <track> elements as React children or Vue default slot.
  • Hover-play with race-safe play/pause. Tracks the play promise so a quick mouse-leave can't trigger a DOMException.
  • hlsConfig is memoizable. Pass a stable reference (useMemo / shallowRef) to avoid HLS rebuilds on render.
  • TypeScript types, full source maps, MIT licensed.
  • Smoke tests in vitest (8 React, 7 Vue).

Bundle size: ~3 KB JS gzipped + ~1 KB CSS gzipped, per package.


What's not in v1.0.2 (yet)

  • Picture-in-Picture toggle — the API is trivial, the UI affordance isn't. Holding off until I know how it should look in the toggle pill.
  • Playback speed control — same. Will land when I find a non-busy way to expose it.
  • Audio language switcher — for HLS streams with multiple audio renditions (dubs, descriptive audio, secondary languages). hls.js exposes audioTracks and audioTrack already, so the wiring is small; the open question is the UI affordance, same as PiP.
  • Caption track UI. You can pass <track> elements but the component doesn't render a captions menu. Native browser controls (controls={true}) handle this for now.
  • An actual stable Nuxt module ecosystem release — currently the module exists and works, but isn't on https://nuxt.com/modules. That's a separate process I'll do when the API has settled for a quarter or two.

Try it

# React
npm install @glitchlab/react-video-player hls.js

# Vue
npm install @glitchlab/vue-video-player hls.js

Enter fullscreen mode Exit fullscreen mode

// React + Next.js App Router
import { ReactVideoPlayer } from "@glitchlab/react-video-player";
import "@glitchlab/react-video-player/style.css";

export default function Page() {
  return <ReactVideoPlayer src="/videos/hero.m3u8" controls />;
}

Enter fullscreen mode Exit fullscreen mode

// Nuxt 3
export default defineNuxtConfig({
  modules: ["@glitchlab/vue-video-player/nuxt"],
  css: ["@glitchlab/vue-video-player/style.css"],
});

Enter fullscreen mode Exit fullscreen mode

<!-- anywhere in your Nuxt app -->
<VueVideoPlayer src="/videos/hero.m3u8" :controls="true" />

Enter fullscreen mode Exit fullscreen mode

Live demo: https://video-player-playgraound.vercel.app/
React package: https://www.npmjs.com/package/@glitchlab/react-video-player
Vue package: https://www.npmjs.com/package/@glitchlab/vue-video-player

Source: https://github.com/im-fahad/react-video-player and https://github.com/im-fahad/vue-video-player.

Issues, PRs, and feature requests welcome. If something's broken in your setup, the playground is the fastest way to reproduce it — drop your URL in, screenshot what you see, file an issue.


If you got value from this, the cheapest way to support is hitting the GitHub star button or sharing the playground link with someone fighting the same CSS-bleed problem. Both packages are MIT and will stay that way.