You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple Next.js progressbar component using [NProgress](http://ricostacruz.com/nprogress/).
3
+
A simple Next.js progressbar component using [NProgress](http://ricostacruz.com/nprogress/) with support of next.js 13 app dir.
4
4
5
-
> [I've created this Blog to help you create your own progressbar](https://gosink.in/next-js-make-your-own-progress-bar-indicator-component-easily/)
5
+
<!--> [I've created this Blog to help you create your own progressbar](https://gosink.in/next-js-make-your-own-progress-bar-indicator-component-easily/)-->
After installing the package, import `NextNProgress`in your `pages/_app.js` file:
17
+
After installing the package, create `providers.tsx` file in app directory to handle contexts and mark it `use client`. see [contexts in app dir](https://nextjs.org/docs/getting-started/react-essentials#context) and import `NProvider;
18
18
19
-
```js
20
-
importNextNProgressfrom'nextjs-progressbar';
19
+
```jsx
20
+
'use client';
21
+
importReactfrom'react';
22
+
import { NProvider } from'next13-progressbar';
23
+
24
+
constProviders= ({ children }: { children:React.ReactNode }) => {
-`color`: to change the default color of progressbar. You can also use `rgb(,,)` or `rgba(,,,)`.
@@ -53,10 +82,10 @@ If no props are passed to `<NextNProgress />`, below is the default configuratio
53
82
54
83
#### Adding nonce
55
84
56
-
We use internal css in this package. If you are using csp, you can add nonce to the `<style>` tag by providing `nonce` prop to `<NextNProgress />` component.
85
+
We use internal css in this package. If you are using csp, you can add nonce to the `<style>` tag by providing `nonce` prop to `<NProvider />` component.
57
86
58
87
```jsx
59
-
<NextNProgress nonce="my-nonce"/>
88
+
<NProvider nonce="my-nonce"/>
60
89
```
61
90
62
91
#### Custom CSS
@@ -65,7 +94,7 @@ You can use `transformCSS` prop to pass custom css.
65
94
**Note:** You must return a `JSX.Element` from the function.
66
95
67
96
```jsx
68
-
<NextNProgress
97
+
<NProvider
69
98
transformCSS={(css) => {
70
99
// css is the default css string. You can modify it and return it or return your own css.
71
100
return<style>{css}</style>;
@@ -78,5 +107,13 @@ You can use `transformCSS` prop to pass custom css.
78
107
You can use [other configurations](https://github.com/rstacruz/nprogress#configuration) which NProgress provides by adding a JSON in `options` props.
0 commit comments