@bprogress/react
Version:
Utility to create your own NProgress bar like with React
76 lines (54 loc) • 1.9 kB
Markdown
Create your own **progress bar** with **React**
```tsx
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.
- [Next.js](https://bprogress.vercel.app/docs/next/installation)
- [Remix](https://bprogress.vercel.app/docs/remix/installation)
- More soon...
```tsx
<ProgressProvider>...</ProgressProvider>
```
```tsx title="src/index.tsx"
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>,
);
```
```tsx title="src/App.tsx"
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;
```
Go to the [documentation](https://bprogress.vercel.app/docs/react/installation) to learn more about BProgress.
If you encounter any problems, do not hesitate to [open an issue](https://github.com/imskyleen/bprogress/issues) or make a PR [here](https://github.com/imskyleen/bprogress).
MIT