Socket
Socket
Sign inDemoInstall

icefog

Package Overview
Dependencies
3
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    icefog

a utility for passing environment/config info from server to client


Version published
Weekly downloads
155
decreased by-51.71%
Maintainers
1
Install size
65.4 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 15 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc