@bprogress/next

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

NProgress bar like for Next.js compatible with new app directory

原始使用文档
文档目录12 节
  1. Migration from next-nprogress-bar
  2. Installation
  3. Import
  4. App Directory
  5. Pages Directory
  6. Usage
  7. Example
  8. App Directory
  9. Pages Directory
  10. More information on documentation
  11. Issues
  12. LICENSE

BProgress for Next.js

BProgress integration on Next.js compatible with /app and /pages directory.

Next NProgress Bar and NProgress V2 become BProgress!

Migration from next-nprogress-bar

If you are using next-nprogress-bar, you can migrate to @bprogress/next by following the migration guide.

Installation

To install BProgress, run the following command:

npm install @bprogress/next

Import

App Directory

Import into your /app/layout(.js/.jsx/.ts/.tsx) folder.

import { ProgressProvider } from '@bprogress/next/app';

Pages Directory

Import into your /pages/_app(.js/.jsx/.ts/.tsx) folder.

import { ProgressProvider } from '@bprogress/next/pages';

Usage

<ProgressProvider>...</ProgressProvider>

Example

App Directory

First approach in a use client layout.

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

import { ProgressProvider } from '@bprogress/next/app';

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <ProgressProvider
          height="4px"
          color="#fffd00"
          options={{ showSpinner: false }}
          shallowRouting
        >
          {children}
        </ProgressProvider>
      </body>
    </html>
  );
}

Second approach wrap in a use client Providers component. (Recommended)

Create a Providers component to wrap your application with all the components requiring 'use client', such as BProgress or your different contexts...

// In /app/providers.tsx
'use client';

import { ProgressProvider } from '@bprogress/next/app';

const Providers = ({ children }: { children: React.ReactNode }) => {
  return (
    <ProgressProvider
      height="4px"
      color="#fffd00"
      options={{ showSpinner: false }}
      shallowRouting
    >
      {children}
    </ProgressProvider>
  );
};

export default Providers;

Then wrap your application with the Providers component.

// In /app/layout.tsx
import Providers from './providers';

export const metadata = {
  title: 'Create Next App',
  description: 'Generated by create next app',
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}

Pages Directory

// In /pages/_app.tsx
import type { AppProps } from 'next/app';
import { ProgressProvider } from '@bprogress/next/pages';

export default function App({ Component, pageProps }: AppProps) {
  return (
    <ProgressProvider
      height="4px"
      color="#fffd00"
      options={{ showSpinner: false }}
      shallowRouting
    >
      <Component {...pageProps} />
    </ProgressProvider>
  );
}

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/next 共发布 30 个版本,首次发布于 2025/02/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.2.12latest2025/04/141.6 年前
3.2.112025/04/101.6 年前
3.2.102025/03/151.7 年前
3.2.92025/03/141.7 年前
3.2.82025/03/121.7 年前
3.2.72025/03/111.7 年前

关于 @bprogress/next 的常见问题

@bprogress/next 是什么?

NProgress bar like for Next.js compatible with new app directory

如何安装 @bprogress/next?

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

@bprogress/next 支持 TypeScript 吗?

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

@bprogress/next 支持 ESM 还是 CommonJS?

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

@bprogress/next 可以商用吗?

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

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

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

@bprogress/next 还在维护吗?

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