2.1.0 • Published 7 months ago

icefog v2.1.0

Weekly downloads
181
License
MIT
Repository
-
Last release
7 months ago

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 add this string to your rendered markup
// e.g. - `<div id="app" ${configString}></div>`

Then on the client, read the config string:

import 'icefog/init' // for the default element of '#app'

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) // do development-specific things

api

createConfig

createConfig(config: object): string

initConifg

initConfig(elementId: string = 'app', { windowAttr: string = 'app' })

  • elementId is the DOM element you render the configString onto
  • windowAttr 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

2.1.0

7 months ago

2.0.0-next.2

11 months ago

2.0.0-next.0

11 months ago

2.0.0-next.1

11 months ago

2.0.0

11 months ago

1.1.2

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.9.9

3 years ago

0.9.8

3 years ago

0.9.7

3 years ago

0.9.6

3 years ago

0.9.5

3 years ago

0.9.4

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago