-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
docs(js): Update Electron quick start guide #15298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments around setup and preload.
Basically we don't want the SDK setup to vary by Electron config because it's not required and too complex.
### Configure the Renderer Process | ||
|
||
```javascript | ||
Initialize the SDK in your Electron renderer process. You can do this in either a preload script (`preload.(js|ts)`) or directly in your renderer script (`renderer.(js|ts)`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With contextIsolation: true
, you cannot configure in either preload/renderer, you would need to configure the SDK in both. However see below for more explanation around this...
Basically, just instruct users to init in the renderer(s)
Initialize the SDK in your Electron renderer processes:
I wouldn't specifically mention file names (ie. renderer.(js|ts)
) because these file names can vary depending on framework or whatever template the app was created from.
<Expandable title="Should you use a preload script or renderer script?"> | ||
|
||
Choose based on your app's setup: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If contextIsolation: true
(Electron default/recommended), the preload and renderer code run in different isolated contexts. This means technically, if you want to catch errors in both preload and renderer contexts, you should init the SDK in both.
If contextIsolation: false
, the preload and renderer code run in the same context so you could technically just init in one of preload/renderer and it would capture errors from both.
However, many users starting out with Electron won't even know what a preload script is. Preload scripts need to be bundled so helping users configure them is non-trivial. We don't actually need the preload to be configured for the SDK to work and we don't want the SDK setup to vary by Electron configuration.
Regardless of Electron configuration, the most reliable way to have the SDK just work in the majority of cases is to init in the main and init in all renderers and just ignore the preload entirely.
Preload configuration is more of an advanced topic and won't be needed by most users.
``` | ||
|
||
## Offline Support | ||
## Step 3: Offline Support (Optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't even mention Offline Support
in the basic intro docs.
I also wouldn't say that this is (Optional)
either because it's enabled by default and most users don't need to worry about it.
DESCRIBE YOUR PR
This PR focuses on transforming the existing Electron guide into a Quick Start guide.
Notes:
Next steps:
You will notice that I haven't changed much for Steps number 3,4,5, and 7. The content in these sections seems to advanced for a quick start guide.
I plan to create a follow-up ticket to move this content to other pages within the Electron docs (of course, we will link to them from the quick start guide).
I noticed that @timfish handles a lot of the Electron SDK work, and you seem like the person to involve when changing the docs. Is that correct? If so, I will @ you in the follow-up ticket so we can align on the changes.
Thanks!!
Closes #15269
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
EXTRA RESOURCES