Introduction
Oneki.js recommends placing the configuration settings in a central location. In general, the configuration is placed in the src/settings.ts file.
;The file name "settings.ts" is a convention and could be anything else. In fact, Oneki.js expects to receive a "Settings" object when it starts and this object can come from anywhere.
- Vite App
- Nextjs App
import { App } from 'onekijs';
import settings from '../settings';
<App settings={settings} />
My-App
│ ├─ src
| | ├─ pages
| | | └─ index.tsx
| | |
| | └─ settings.ts
│
├─ .gitignore
├─ package.json
├─ README.md
├─ yarn.lock
import { AppProps } from 'next/app';
import { NextApp } from 'onekijs-next';
import settings from '../settings';
const MyApp: FC<AppProps> = (props) => {
return <NextApp settings={settings} />;
};
My-App
│ ├─ src
| | ├─ pages
| | | ├─ _app.js
| | | └─ index.tsx
| | |
| | └─ settings.ts
│
├─ .gitignore
├─ package.json
├─ README.md
├─ yarn.lock
The contents of settings.ts are available throughout the application via the useSettings hook and are also automatically injected into all reducers and saga
Some framework components use the contents of settings.ts to configure themselves. For example, the notification service is configured like this:
// content of settings.ts
export default {
notification: {
default: {
ttl: 1000, // the number of milliseconds the notification is visible
max: 5
},
error: {
ttl: 0, // if the notification is an error, it never disappears by itself
max: 3,
persist: true
}
}
};
For more information about booting an Oneki.js application, see the App component documentation page.