New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

embed-react-app-envs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embed-react-app-envs

Script for embedding environment variable in CRA apps without having to rebuild the on the server.

Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
16
220%
Maintainers
1
Weekly downloads
 
Created
Source

Safely bundle server's environnement variable into react apps

Motivation

Create react app provides no official way to inject environnement variable from the server into the page. When you run yarn build create react app do bundle all the variables prefixed by REACT_APP_ and expose them under process.env (see here).
The problem, however is that you likely don't want to build your app on the server.
The CRA team also suggest to introduce placeholders in the public/index.html and do the substitution on the server before serving the app. This solution involves a lot of hard to maintain scripting.

This module abstract away the burden of managing environnement variable injection as well as providing a type safe way to retrieve them in your code (using TypeScript).

FAQs

Package last updated on 13 Mar 2021

Did you know?

Socket

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