Changelog

CodeSandbox SDK RC
We are back with a major update to CodeSandbox SDK, which we're officially announcing soon.
Hello there 👋
We've been hard at work over the past few months building the new CodeSandbox SDK to allow you to use CodeSandbox infrastructure and features in new and exciting ways.
We'd like to take this opportunity to thank you, our early adopters. You've provided us with your detailed feedback, worked with us to debug problems and more broadly, you've stuck with us!
As the SDK has matured, a common theme in your feedback has been that the API hasn't been as intuitive as you and we would like it to be. This release candidate includes a comprehensive overhaul of the surface API to make it more accessible, consistent and also make it easier for us to support more features in the future.
We encourage you to read through the RC Docs and use the shiny new playground to test some of these new features (playground sneak peek below).
Try the new SDK now: npm install @codesandbox/sdk@rc
Mental model
Before we jump into the new features, let's do a quick recap of the mental model to use the new SDK:
// Management of all resources
const sdk = new CodeSandbox();
// Management of preview tokens
sdk.previewTokens;
// Management of sandboxes
sdk.sandboxes;
For sandbox resources, the mental model is:
// Manage sandboxes without a session
sdk.sandboxes.create();
sdk.sandboxes.resume("sandbox-id");
sdk.sandboxes.restart("sandbox-id");
sdk.sandboxes.shutdown("sandbox-id");
sdk.sandboxes.hibernate("sandbox-id");
// Create a session to interact
sandbox.connect();
sandbox.createBrowserSession();
sandbox.createRestSession();
What's new?
Support for environment variables 🔑
This has been one of the top-requested features for quite a while! Now, the SDK has support for environment variables for your sessions, bound to any command or terminal instances created.
Select a git source ✔️
You can now select a git source for a Sandbox, which allows you to clone a repo.
Preview API 📺
Our new Preview API allows you to interact with the preview iFrame in the browser. You can try this now on our playground!
Automatic reconnect handling 🔄️
The browser connection to a Sandbox now has automatic reconnect handling.
Snapshots deployed to all clusters 🌐
Now, when you build templates using the CLI, we will deploy the snapshots to all our clusters. Below you can see an example where the snapshot was deployed to our fc-eu-2
and fc-us-1
clusters (several additional clusters are available).

Other New Features & Improvements
Tasks are now enhanced with features to manage the task and open its shell output.
You can now pass Git credentials to a session to manage git in a Sandbox.
CodeSandbox SDK Breaking Changes
If you are moving from 0.12.x
to the release candidate, it can be a good idea to read through the docs, as there are several surface API changes. The most noticeable are:
shells
are removed in favor of higher dedicated abstractions calledterminals
,commands
,interpreters
,setup
andtasks
. They all abstract the lower-level shell with accessible methods and behaviors for consuming the underlying shells.- Separation of Sandbox instance and Sessions.
And there you have it!
We hope you're as excited as we are about all these updates, especially as we get closer to a full release.
Thank you again for continuing to share your feedback with us to help us make the SDK better for everyone.
Have fun building and see you soon 👋