sushinpv / react-secure-storage

This is a wrapper written above local storage to write the data securely to local storage
https://npmjs.com/package/react-secure-storage
MIT License
126 stars 12 forks source link

how to solve process not defined in Remix #29

Closed yarapolana closed 1 year ago

yarapolana commented 1 year ago

I am using Remix and haven't found a workaround to solve process not defined, in the other resolved issues, you mentioned webpack and prefixes from vite, next, and react, which don't work in my case.

Is there a workaround? A custom config option somewhere? Thanks in advance

sushinpv commented 1 year ago

Hi @yarapolana,

There is a workaround to define process in Remix code, You can use that temporarily, Soon we will add support for Remix directly in the library itself,

To define process you can create an inline script with following code.

<script
  dangerouslySetInnerHTML={{
    __html: `window.process = ${JSON.stringify({
      env: {}, 
    })}`,
  }}
/>

You can also find more information here https://github.com/remix-run/remix/discussions/4906 https://sergiodxa.com/articles/use-process-env-client-side-with-remix

yarapolana commented 1 year ago

@sushinpv Wow, thank you for the fast reply. Didn't see this until now. Works like a charm!

The only thing I changed was ... JSON.stringify(env) instead of ... JSON.stringify({ env: ... })