icefog
a utility for passing environment/config info from server to client
install
yarn add icefog
use
On the server, create a config string:
import { createConfig } from 'icefog/server'
const configString = createConfig({ isDev: true, token: 'abc' })
Then on the client, read the config string:
import 'icefog/init'
or
import { initConfig } from 'icefog'
initConfig('my-dom-element')
the config
export is then available for use anywhere in your app:
import { config } from 'icefog'
if (config.isDev)
api
createConfig
createConfig(config: object): string
initConifg
initConfig(elementId: string = 'app', { windowAttr: string = 'app' })
elementId
is the DOM element you render the configString ontowindowAttr
is only used if config.isDev
is true, and will attach the config to this window
attribute
config
Effectively the object you provided to createConfig
, with any functions stripped