Skip to content

Commit 29c0b15

Browse files
committed
Add missing usage examples
1 parent 843ffc4 commit 29c0b15

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,52 @@ returns.
4141
values retrieved from `next/config`, and compatible `get()` and `has()`
4242
methods.
4343

44+
## Usage
45+
46+
Add some configuration files, for example `config/default.js`, then add the
47+
plugin to `next.config.js`.
48+
49+
Simplest usage with no existing Next.js config:
50+
51+
```js
52+
const withNodeConfig = require('next-plugin-node-config');
53+
54+
module.exports = withNodeConfig();
55+
```
56+
57+
With existing Next.js config:
58+
59+
```js
60+
const withNodeConfig = require('next-plugin-node-config');
61+
62+
module.exports = withNodeConfig({
63+
// These will be merged on top of anything that comes from `config`!
64+
serverRuntimeConfig: {
65+
secret: 'entropy9'
66+
},
67+
publicRuntimeConfig: {
68+
api: '/graphql'
69+
},
70+
webpack(config, options) {
71+
// ...
72+
return config;
73+
}
74+
});
75+
```
76+
77+
Using the `nodeConfigServerKey` and `nodeConfigPublicKey` options,
78+
`serverRuntimeConfig` and `publicRuntimeConfig` can be named something nicer in
79+
your config files:
80+
81+
```js
82+
const withNodeConfig = require('next-plugin-node-config');
83+
84+
module.exports = withNodeConfig({
85+
nodeConfigServerKey: 'server',
86+
nodeConfigPublicKey: 'public'
87+
});
88+
```
89+
4490
[node-config]: https://github.com/lorenwest/node-config
4591
[next-config]: https://github.com/zeit/next.js#exposing-configuration-to-the-server--client-side
4692
[files]: https://github.com/lorenwest/node-config/wiki/Configuration-Files

0 commit comments

Comments
 (0)