Config โ
The mono-repo also comes with a config file that handles cookies, JWT state, and deployment.
The config lives in a single file:
mono-remote/
โโโ mono.config.ts
โโโ ...etc/Cookie โ
Handling a cookie is simple. Say you have a cookie called JWT_Token that's already set, and you want to use it across your app โ here's a small example.
ts
//@unocss-include
import { defineConfig, JWTCompleteTokenTypes } from "mono-utils/runtime";
export default defineConfig({
name: 'mono-remote',
cookie: [
{
name: 'JWT_Token',
},
],
});Then use it like this โ it returns the exact value of your token:
ts
import { monoState } from 'mono-utils/state';
const token = monoState().cookie.JWT_Token
console.log(token)JWT โ
What if you need to decode the JWT_Token cookie to read the JWT payload inside? Set it up like this:
ts
//@unocss-include
import { defineConfig, JWTCompleteTokenTypes } from "mono-utils/runtime";
export default defineConfig({
name: 'mono-remote', // your app name
jwt: {
token: {
name: 'JWT_Token',
},
},
});Then use it like this โ the token returns the decoded value:
ts
import { monoState } from 'mono-utils/state';
const { jwt } = monoState()
console.log(jwt.token)Deployment โ
Deployment is fully handled by the Host, so the Host needs to know which Remote pages to deploy.
For example, a Remote has a page called budget.vue:
mono-remote/
โโโ src/
โโโ pages/
โโโ budget.vueTo have the Host deploy it, define it in the config. You can use any icon from Icones.
ts
import { defineConfig, JWTCompleteTokenTypes } from "mono-utils/runtime";
export default defineConfig({
name: 'mono-remote',
menu: [
{
title: 'Budget',
url: '/budget',
icon: 'i-mdi-wallet-bifold',
}
]
});