Local Development / polyfill help

The steps I follow at the moment (they may become obsolete when the new Authenticator and safe_client_libs get released) to create a SAFE web app are the following:

  1. Install nodejs and create the skeleton of the app with create-react-app
  2. Add safe-js module to the app: npm install safe-js --save
  3. Place the following code in your app:
if (process.env.NODE_ENV !== 'production') {
   require('safe-js/dist/polyfill')
}
  1. Place your code which calls the safe-js functions, e.g. window.safeAuth.authorise(app).
  2. Run the SAFE Launcher.
  3. Run your app: npm start
  4. Open the SAFE Browser, and select from the menu: “BeakerDev” → “Toggle WebSecurity for new tabs”
  5. Open a new tab on the browser, and go to your web app’s URL, e.g. http://localhost:3000

You might need to manually patch the polyfill.js located at node_modules/safe-js/dist/polyfill.js if you invoke window.safeStructuredData.readData (see issue 21)

2 Likes