DEV Community

Tyler Smith
Tyler Smith

Posted on

How to Open a CodeSandbox Project Without a Browser Preview

From time to time, we all write really bad code. Sometimes, that code is a poorly-written JavaScript loop that completely locks the main thread and prevents anything else from working in that browser tab. If you're working in a standalone text editor, this isn't a big deal: you kill the browser tab, fix your code, then reopen the browser tab to see if your code works.

However, if you're using CodeSandbox, your code is execute in the same tab as the editor. This can make it impossible to fix the bug that's locking the main thread. Thankfully, CodeSandbox has an undocumented way of getting around this.

If you append &runonclick=1 to the end of a project's URL, it will prevent the code preview from running until you click into the preview window. This will allow you to fix your buggy code before it locks up the main thread.

At the time of writing this post, there is no way to do this through the UI.

Thank you to garethx for posting this solution to a GitHub issue!

Top comments (0)