@bprogress/react

中文文档
1.2.7发布于 2025/04/14MITTypeScriptESM + CJS近 30 天下载 137.4万

Utility to create your own NProgress bar like with React

原始使用文档
文档目录7 节
  1. Import
  2. React Frameworks Integrations
  3. Usage
  4. Example
  5. More information on documentation
  6. Issues
  7. LICENSE

BProgress for React

Create your own progress bar with React

Import

import { ProgressProvider } from '@bprogress/react';

The @bprogress/react package is a utility that lets you easily manage a progress bar, while remaining flexible with regard to the router you're using. It doesn't automatically start the progress bar when browsing, so you'll have to manage this logic yourself, unless you're using one of the integrations below.

React Frameworks Integrations

Usage

<ProgressProvider>...</ProgressProvider>

Example

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { ProgressProvider } from '@bprogress/react';

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement,
);
root.render(
  <React.StrictMode>
    <ProgressProvider>
      <App />
    </ProgressProvider>
  </React.StrictMode>,
);
import { useProgress } from '@bprogress/react';

function App() {
  const { start, stop, pause, resume } = useProgress();

  return (
    <div className="App">
      <button onClick={start}>Start</button>
      <button onClick={stop}>Stop</button>
      <button onClick={pause}>Pause</button>
      <button onClick={resume}>Resume</button>
    </div>
  );
}

export default App;

More information on documentation

Go to the documentation to learn more about BProgress.

Issues

If you encounter any problems, do not hesitate to open an issue or make a PR here.

LICENSE

MIT

版本与发布记录

@bprogress/react 共发布 20 个版本,首次发布于 2025/02/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.7latest2025/04/141.6 年前
1.2.62025/04/101.6 年前
1.2.52025/03/151.7 年前
1.2.42025/03/141.7 年前
1.2.32025/03/121.7 年前
1.2.22025/03/111.7 年前

关于 @bprogress/react 的常见问题

@bprogress/react 是什么?

Utility to create your own NProgress bar like with React

如何安装 @bprogress/react?

在项目目录运行 npm install @bprogress/react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.0.0)、react-dom(>=18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bprogress/react 支持 TypeScript 吗?

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

@bprogress/react 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bprogress/react 可以商用吗?

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

@bprogress/react 的下载量有多少?

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

@bprogress/react 还在维护吗?

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