Make useable in all js environments
See original GitHub issueThe branch sdk should check if window exists before utilizing it. See https://github.com/BranchMetrics/smart-app-banner-branch-deep-linking-web-library/blob/master/dist/build.js#L1845
This was only discovered while running branch in a worker thread, as window
is not available in that environment.
![screen shot 2016-06-15 at 2 31 33 pm](https://cloud.githubusercontent.com/assets/587438/16092470/0208bab0-3306-11e6-99c0-2632787c8efa.png)
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (3 by maintainers)
Top Results From Across the Web
Setting Environment Variables for Node to retrieve
Environment variables (in this case) are being used to pass credentials to your application. USER_ID and USER_KEY can both be accessed from process.env....
Read more >Node.js Everywhere with Environment Variables! - Medium
env file is a great way to see all of your environment variables in one place. Just be sure not to put them...
Read more >Setting up a Node development environment - MDN Web Docs
You now have a Node development environment up and running on your computer that can be used for creating Express web applications.
Read more >Environment variables in Next.js and Netlify
If you'd like to use environment variables in Next.js, make a .env.local file at the root and you can use them all there!...
Read more >Building A JavaScript App VS Building A JavaScript Library
Compiling It · Making It Usable From Various Apps · Choosing Supported Output Formats · Choosing Supported Target Environments · Be Careful With...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
yep it is because of server-side rendering, you have lines like
return navigator.isCookieEnable
which will failWorkaround may be using branch only on the client, use async chunk for example
Hey Team,
Thank you for your feedback. To get our WebSDK operable in environments where the window object is not available is a significant undertaking for the team (as you’ve seen through searching for references to the ‘window’ object).
We’ve found another area that that would need to be re-tested/potentially re-written as a result of this change. That area is related to storage i.e. how we use application, local and cookie storage in the WebSDK to store and retrieve items related to our core deep linking functionality.
We do understand your frustration though so we’ve added this as a feature request in our internal WebSDK backlog.
Incase anyone in this thread finds it useful, we have an HTTP API as an alternative:
https://github.com/BranchMetrics/branch-deep-linking-public-api
@pho3nixf1re regarding using Branch with a server side rendered react app, I wanted to share a technique I used to make Branch work in this environment.
Using the example at the following location:
https://github.com/mhart/react-server-example
I made the following changes:
at: https://github.com/mhart/react-server-example/blob/master/App.js#L18
This worked well for me. Please feel free to shoot an email to integrations@branch.io if you’re having trouble with React and Branch.
@morenoh149 thanks for calling out the .sdk_version issue - we’ve added it to our backlog.