Skip to content

Commit faceb50

Browse files
authored
chore: add synced templates under Sandboxes and update its content (#268)
* chore: add synced templates under Sandboxes and update its content * chore: improve clarity
1 parent 9a2c983 commit faceb50

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

packages/projects-docs/pages/learn/devboxes/synced-templates.mdx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,30 @@ Synced templates are [templates](https://codesandbox.io/docs/learn/devboxes/temp
2020

2121
CodeSandbox also has [Repositories](https://codesandbox.io/docs/learn/repositories/overview), which are also imported from GitHub repositories. However, there is a key difference between synced templates and repositories.
2222

23-
Repositories are meant for working on a repository. We introduce a workflow to create new branches and pull requests. Synced templates allow you to create a sandbox template from a repository (or folder), and are meant to be used as a template for new sandboxes (or for sharing as an example with others).
23+
Repositories are meant for working on a repository. We introduce a workflow to create new branches and pull requests. Synced templates allow you to create a Devbox/Sandbox template from a repository (or folder), and are meant to be used as a template for new projects (or for sharing as an example with others).
2424

2525
A good rule of thumb is that if you want to work on a repository, you should import a repository. If you want to create a template from a repository, you should create a synced template from a GitHub repository.
2626

2727
## Creating a synced template
2828

29-
A synced template URL is essentially the same as the GitHub URL, but `github.com` is replaced with `codesandbox.io/p/devbox/github`. Because of this, you can go to your GitHub repository, and replace `github.com` with `codesandbox.io/p/devbox/github` to create a synced template. We have also introduced three helpers to do this more easily:
29+
A synced template runs code from a GitHub branch in CodeSandbox and keeps the changes synced with remote. A synced template can either be a Sandbox or a Devbox. You can tell the difference by the way the URL is constructed:
3030

31-
https://codesandbox.io/p/devbox/github/withastro/astro/main/examples/blog
31+
- A synced template as a Devbox will look something like this: `codesandbox.io/p/devbox/github`.
32+
- A synced template as a Sandbox will look something like this: `codesandbox.io/p/sandbox/github`.
33+
34+
As explained below, you can create synced templates directly from the GitHub URL or through our GitHub importer tool.
3235

3336
### Directly from the GitHub URL
3437

35-
First, visit the GitHub repository or folder from which you want to create a synced template. The URL should look something like `https://github.com/owner/repo` for a repository and `https://github.com/owner/repo/tree/main/folder` for a folder.
38+
First, visit the GitHub repository or folder from which you want to create a synced template. The URL should look like `https://github.com/owner/repo` for a repository and `https://github.com/owner/repo/tree/main/folder` for a folder.
3639

3740
Then, replace `github.com` with `githubbox.com` and press Enter.
3841

3942
This will redirect you to a URL that looks like `https://codesandbox.io/p/devbox/github/owner/repo` or `https://codesandbox.io/p/devbox/github/owner/repo/tree/main/folder`, which is the location of the newly created synced template!
4043

4144
### Using our GitHub importer
4245

43-
Go to our ["New Sandbox" modal](https://codesandbox.io/s) and click on the "Import template" button. Enter the GitHub URL you want to import in the input field and press "Open URL". This will redirect you to the location of the synced template.
46+
Go to our ["Repo Import" modal](https://codesandbox.io/dashboard?import_repo=true) and click on "Import template". Enter the GitHub URL you want to import in the input field and press "Open URL". This will redirect you to the location of the synced template.
4447

4548
### Using a Browser Extension
4649

@@ -81,8 +84,10 @@ After you've created this file and opened the synced template at least once, you
8184

8285
## VM behavior of synced templates
8386

84-
For our [Devboxes](https://codesandbox.io/docs/learn/sandboxes/overview?tab=cloud), we run your sandbox in a microVM. We try to automatically detect from your repository contents whether your project is more suited for a Devbox than a browser sandbox. To force the template to load as a Devbox, you can create a `.devcontainer/devcontainer.json` file in your repository. This file should contain a valid [Devcontainer configuration](https://codesandbox.io/docs/learn/environment/devcontainers) that we'll use to build your Devbox.
87+
We try to automatically detect from your repository contents whether your project is more suited for a Devbox (which runs in a VM) than a Sandbox (which runs on the browser).
88+
89+
To force the template to load as a Devbox, you can create a `.devcontainer/devcontainer.json` file in your repository. This file should contain a valid [Dev Container configuration](https://codesandbox.io/docs/learn/environment/devcontainers) that we'll use to build your Devbox.
8590

86-
We use memory snapshotting to resume a VM quickly when someone visits it. To ensure that visitors of your sandbox will always get the latest contents of your GitHub repository, we base the memory snapshot on the latest commit of your repository or folder.
91+
We use memory snapshotting to resume a VM quickly when someone visits it. To ensure that visitors of your Devbox will always get the latest contents of your GitHub repository, we base the memory snapshot on the latest commit of your repository or folder.
8792

88-
This means that if you create a new commit in your repository, we will discard the memory snapshot of the synced template and will start the sandbox from scratch on next visit. During the VM boot, we will download the latest file contents from the repository. This ensures that visitors to your sandbox will always get the latest contents of your GitHub repository, but it also means that the first visit of your sandbox after a commit can be slower than usual (only for memory; we do still keep the filesystem between invalidations).
93+
This means that if you create a new commit in your repository, we will discard the memory snapshot of the synced template and will start the Devbox from scratch on next visit. During the VM boot, we will download the latest file contents from the repository. This ensures that visitors to your Devbox will always get the latest contents of your GitHub repository, but it also means that the first visit of your Devbox after a commit can be slower than usual (only for memory; we do still keep the filesystem between invalidations).

packages/projects-docs/pages/learn/sandboxes/_meta.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
"cli-api": "CLI & API",
66
"embedding": "Embedding",
77
"custom-npm-registry": "Custom NPM Registry",
8+
"synced-templates": {
9+
"title": "Synced Templates",
10+
"href": "/learn/devboxes/synced-templates"
11+
},
812
"faq": "FAQ"
913
}

0 commit comments

Comments
 (0)