You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platform/webcontainers/browser-config.md
+65-16Lines changed: 65 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -16,23 +16,54 @@ WebContainers use a combination of browser technologies, such as [Service Worker
16
16
17
17
In some browsers, this feature is blocked by “third-party cookie” or “third-party storage” restrictions. These are legitimate restrictions when the third-party domain is an ad server or a tracking server, but in the case of WebContainers the third-party domain is where your project code runs.
18
18
19
-
## Chrome: enabling Service Workers {#chrome-service-workers}
19
+
## Chrome
20
20
21
-
If you use the “Block Third Party Cookies” option in Chrome and you have "Third-party Storage Partitioning" disabled, you will need to either:
21
+
With Chrome's defaults, starting with version 118 or later, you should get a pretty good experience out of the box.
22
+
23
+
Read on if you run into issues or want an even smoother experience.
24
+
25
+
### Previews in a separate tab {#chrome-preview-separate-tab}
26
+
27
+
Previews opened in a separate tab are not connected by default to the editor and require an extra step. To complete this step, you are usually prompted to click a button.
28
+
29
+
This can happen automatically if your popups settings, [chrome://settings/content/popups](chrome://settings/content/popups), are adjusted with the following exception:
30
+
31
+
```
32
+
https://[*.]webcontainer.io
33
+
```
34
+
35
+
<imgclass="mx-auto"alt="Chrome popups settings showing the *.webcontainer.io origins as exceptions"src="./assets/chrome-settings-popups.png"width="800"height="502.37" />
36
+
37
+
Once done, whenever the preview needs to reconnect to the editor, it will open a popup that gets immediately closed.
38
+
39
+
Lastly, if Chrome's [memory saver][CHROME_MEMORY_SAVER] is turned on, this step might be necessary more often than required. To avoid it, you can add the following exception in [chrome://settings/performance](chrome://settings/performance):
40
+
41
+
```
42
+
https://webcontainer.io
43
+
https://stackblitz.com
44
+
```
45
+
46
+
Your performance settings should be similar to this:
47
+
48
+
<imgclass="mx-auto"alt="Chrome performance settings showing the memory saver section with an exception for stackblitz.com"src="./assets/chrome-memory-saver.png"width="800"height="502.37" />
49
+
50
+
### Enabling Service Workers {#chrome-service-workers}
51
+
52
+
If you use the “Block Third Party Cookies” option in Chrome and you have “Third-party Storage Partitioning” disabled, you will need to either:
22
53
23
54
- Enable Storage partitioning
24
55
- Or add exceptions for StackBlitz projects.
25
56
26
57
The first option should be preferred because this is a [new feature][GOOGLE_SP] of Chrome which improves your privacy when you visit websites that embed third-party sites.
27
58
28
-
### Enable Storage partitioning
59
+
####Enable Storage partitioning
29
60
30
61
Visit `chrome://flags/#third-party-storage-partitioning` and choose `Enabled` in the drop down. In recent version of Chrome, choosing the `Default` value should work too.
31
62
32
-
<imgalt="Chrome flags showing the third-party Storage Partitioning option enabled."src="./assets/chrome-enable-sp.png"width="800" />
63
+
<imgalt="Chrome flags showing the third-party Storage Partitioning option enabled."src="./assets/chrome-enable-sp.png"width="800"height="234.56"/>
33
64
34
65
35
-
### Or add exceptions for Stackblitz
66
+
####Or add exceptions for Stackblitz
36
67
37
68
To allow all StackBlitz projects to use Service Workers, go to your browser’s cookie preferences, and add exceptions for the following URL patterns:
38
69
@@ -43,11 +74,11 @@ https://[*.]webcontainer.io
43
74
44
75
For instance, in Chrome, go to `chrome://settings/cookies` and add those exceptions in the “Sites that can always use cookies” section.
45
76
46
-
<imgalt="Chrome cookie settings with an empty list of “Sites that can always use cookies”."src="./assets/chrome-settings-cookies-1.png"width="800" />
77
+
<imgalt="Chrome cookie settings with an empty list of “Sites that can always use cookies”."src="./assets/chrome-settings-cookies-1.png"width="800"height="600"/>
47
78
48
-
<imgalt="Chrome cookie settings showing a modal dialog for adding a site to list of third-party cookie exceptions."src="./assets/chrome-settings-cookies-2.png"width="800" />
79
+
<imgalt="Chrome cookie settings showing a modal dialog for adding a site to list of third-party cookie exceptions."src="./assets/chrome-settings-cookies-2.png"width="800"height="600"/>
49
80
50
-
<imgalt="Chrome cookie settings with exceptions for stackblitz.io and local.webcontainer.io domains."src="./assets/chrome-settings-cookies-3.png"width="800" />
81
+
<imgalt="Chrome cookie settings with exceptions for stackblitz.io and local.webcontainer.io domains."src="./assets/chrome-settings-cookies-3.png"width="800"height="600"/>
51
82
52
83
:::details Advanced: enabling Service Workers for a single project
53
84
@@ -67,7 +98,9 @@ Note that the list of blocked domains might look different for you. In particula
67
98
68
99
:::
69
100
70
-
## Firefox: enabling Service Workers {#firefox-service-workers}
101
+
## Firefox
102
+
103
+
### Enabling Service Workers {#firefox-service-workers}
71
104
72
105
When Firefox’s Enhanced Tracking Protection is configured in “Custom” mode with the cookie blocking option set to “All cross-site cookies”, Firefox will block the Service Workers used by WebContainers.
73
106
@@ -81,7 +114,8 @@ To do so, visit `about:preferences#privacy` to check what your current settings
81
114
<img
82
115
alt="The Firefox “Privacy & Security” settings page showing that Enhanced Tracking Protection is set to “Custom”, and to “Cookies: All cross-site cookies (may cause websites to break)”."
83
116
src="./assets/firefox-settings-cookies-1.png"
84
-
width="1024"
117
+
width="820"
118
+
height="661"
85
119
/>
86
120
87
121
To add exceptions for StackBlitz, scroll down to the “Cookies and Site Data” section, click on “Manage Exceptions…”, and add exceptions for the following sites:
@@ -94,11 +128,25 @@ https://webcontainer.io
94
128
<img
95
129
alt="The Cookies and site data exceptions management window in Firefox settings. It shows a couple entries for stackblitz.io and webcontainer.io, both with the value “Allow”."
96
130
src="./assets/firefox-settings-cookies-2.png"
97
-
width="1024"
131
+
width="820"
132
+
height="645"
98
133
/>
99
134
100
135
Don’t forget to click “Save Changes”. Then you should be able to reload the tab with your StackBlitz project, and hopefully everything should work!
101
136
137
+
### Previews in a separate tab {#firefox-preview-separate-tab}
138
+
139
+
Previews opened in a separate tab are not connected by default to the editor and require an extra step. To complete this step, you are usually prompted to click a button.
140
+
141
+
This can happen automatically if your popups settings, [about:preferences#privacy](about:preferences#privacy), are adjusted with the following exception:
142
+
143
+
```
144
+
https://webcontainer.io
145
+
```
146
+
147
+
<imgalt="Firefox popups settings showing the webcontainer.io site allowed as an exception"src="./assets/firefox-settings-popups.png"width="800"height="649" />
148
+
149
+
102
150
## Brave: enabling Service Workers {#brave-service-workers}
103
151
104
152
By default, Brave’s “Shields” feature blocks [Service Workers][MDN_SERVICE_WORKER] and cookies from third-party domains.
@@ -107,19 +155,19 @@ To allow WebContainers to run in Brave, you will need to add an exception for St
107
155
108
156
1. Visit a WebContainers-based project, for instance https://stackblitz.com/edit/nextjs. The project’s boot sequence might stay stuck on the “Running start command” step:
109
157
110
-

158
+
<imgalt="Screenshot of Brave on a WebContainers project with the Brave Shields feature on. Loading the project’s web server is stuck on the last step"src="./assets/brave-stuck-project.png"width="820"height="500"/>
111
159
112
160
2. Click on the “Shields” icon at the right of the address bar, then click on “Advanced View”.
113
161
114
-
<imgalt="Screenshot showing the Shields configuration popup for stackblitz.com."src="./assets/brave-shields-popup.png"width="380" />
162
+
<imgalt="Screenshot showing the Shields configuration popup for stackblitz.com."src="./assets/brave-shields-popup.png"width="380"height="358"/>
115
163
116
164
3. In the advanced view, change the “Cross-site cookies blocked” option to “All cookies allowed”.
117
165
118
-

166
+
<imgalt="Screenshot showing the advanced view of the Shields configuration popup, with a drop-down selector for cross-site cookie permissions."src="./assets/brave-shields-details.png"width="820"height="559" />
119
167
120
168
Brave will reload the page, and you should get a working project:
121
169
122
-

170
+
<imgalt="Screenshot of Brave on a WebContainers project with the Brave Shields feature tweaked to allow third-party cookies and Service Workers. Loading the web server works, and shows the default page for Next.js’s starter project."src="./assets/brave-working-project.png"width="820"height="500"/>
0 commit comments