create() method provisions a brand-new sandbox container within Fermion’s secure cloud infrastructure. When invoked, it initializes a clean Linux environment, configures your session, and establishes a WebSocket connection for real-time communication. Depending on the options you pass, the sandbox can be either ephemeral (short-lived and automatically destroyed on disconnect) or persistent (saved for later use).
You can also clone a Git repository during provisioning, making it easy to start from existing codebases or templates. The process typically completes within a few seconds, after which the sandbox is ready to accept commands, file operations, or server executions. The method returns a unique snippetId, which you can store and reuse to reconnect to the same environment later.
create(options)
Description:
Creates and provisions a new sandbox container. This process includes:
- Creating a playground snippet
- Starting a session
- Waiting for container provisioning (polling with 500ms intervals)
- Establishing WebSocket connection
- Waiting for container server to be ready
- Optionally cloning a git repository
Returns:
Promise<{ playgroundSnippetId: string }> - Resolves with the playground snippet ID (save this to start another container with same file system later)
Example:
