Skip to content

Latest commit

 

History

History

effect-env

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

@regenerate/effect-env

Regenerate effect to access environment variables

Installation

# Using yarn
yarn add @regenerate/effect-env

# Using npm
npm i @regenerate/effect-env

Set up

Create a src/effects/env.js file in your project with the following content:

import createEnvEffect from '@regenerate/effect-env'

export default createEnvEffect()

By default @regenerate/effect-env will use the variables available in process.env but alternatively you can provide any desired variable when creating it:

import createEnvEffect from '@regenerate/effect-env'

const env = {
  A_VARIABLE: 'a value',
  ANOTHER_VARIABLE: 'another value'
}

export default createEnvEffect({ env })

Usage

function * fetchTodos () {
  const apiBaseUrl = yield env.get('API_BASE_URL')
  // Rest of effects
}