@glomex/integration-react

中文文档
1.1597.2发布于 2026/10/31MITTypeScriptES Module零依赖近 30 天下载 2872

React component to integrate the glomex player

原始使用文档
文档目录4 节
  1. Introduction
  2. About glomex
  3. Usage
  4. Loading & integrating the player (TypeScript)

@glomex/integration-react

Introduction

@glomex/integration-react exposes a React component and types to easily integrate the glomex player. In order to use this component, you need to have a glomex account. You can get one by following the instructions in the Getting Started section.

About glomex

glomex operates Germany’s largest marketplace for premium video content. Our platform connects publishers, content creators, and advertisers, enabling the seamless distribution of high-quality video content across the web.

Our ecosystem is designed to create value for all participants:

  • Publishers gain access to premium video content and monetization opportunities
  • Content Owners receive wide distribution and revenue for their video assets
  • Advertisers reach targeted audiences across a network of quality websites

Usage

Loading & integrating the player (TypeScript)

// example: player.tsx
import { useEffect, useRef, type ComponentProps, type ComponentRef } from 'react';
import { Integration, IntegrationEvent } from '@glomex/integration-react';

const Player = (props: ComponentProps<typeof Integration>) => {
  const integrationRef = useRef<ComponentRef<typeof Integration>>(null);

  const handlePlay = () => {
    integrationRef.current?.ready.then(() => integrationRef.current?.play());
  };

  const handleContentStart = () => {
    console.log('content start', integrationRef.current?.content);
  };

  useEffect(() => {
    integrationRef.current?.ready.then(() => {
      // interact with the API after initial ready
      if (!integrationRef.current) return;
      // e.g. start at 20 seconds
      integrationRef.current.currentTime = 20;
      // integrationRef.current.volume = 0.1
      // integrationRef.current.muted = true
      // integrationRef.current.play();
    });
    // addEventListener is available immediately (without ready)
    integrationRef.current?.addEventListener(
      IntegrationEvent.CONTENT_START,
      handleContentStart
    );
    return () => {
      integrationRef.current?.removeEventListener(
        IntegrationEvent.CONTENT_START,
        handleContentStart
      );
    };
  }, [integrationRef]);

  return (
    <div>
      <Integration
        ref={integrationRef}
        {...props}
      />
      <button type="button" onClick={handlePlay}>
        Play
      </button>
    </div>
  );
};

export default Player;

Usage in your component:

// example: app.tsx
import Player from "./player"

export default async function MyApp(props) {
  const params = await props.params

  return (
    <div>
      <Player
        integrationId="YOUR_INTEGRATION_ID"
        playlistId="YOUR_PLAYLIST_ID"
      />
    </div>
  );
}

版本与发布记录

@glomex/integration-react 共发布 498 个版本,首次发布于 2025/04/07;过去 12 个月发布了 250 个版本。

版本发布日期距今
1.1597.2latest2026/10/3116 天前
1.1596.52026/10/2324 天前
1.1596.42026/10/2324 天前
1.1596.32026/10/2225 天前
1.1596.22026/10/2127 天前
1.1596.12026/10/2027 天前

关于 @glomex/integration-react 的常见问题

@glomex/integration-react 是什么?

React component to integrate the glomex player

如何安装 @glomex/integration-react?

在项目目录运行 npm install @glomex/integration-react,或使用 pnpm add / yarn add / bun add。

@glomex/integration-react 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@glomex/integration-react 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@glomex/integration-react 可以商用吗?

@glomex/integration-react 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@glomex/integration-react 的下载量有多少?

根据 npm 官方下载统计,@glomex/integration-react 在 2026/10/17 – 2026/11/15 这 30 天内被下载 2,872 次,日均约 96 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@glomex/integration-react 还在维护吗?

最新版本 1.1597.2 发布于 2026/10/31(16 天前);至今共发布 498 个版本,其中过去 12 个月发布了 250 个;首次发布于 2025/04/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。