Note: Codespaces is currently in limited public beta and subject to change. For more information about joining the beta, see "About Codespaces."
In this guide, you'll create a codespace from a template repository and explore some of the essential features available to you within the codespace.
From this quickstart, you will learn how to create a codespace, connect to a forwarded port to view your running application, use version control in a codespace, and personalize your setup with extensions.
For more information on exactly how Codespaces works, see the companion guide "Deep dive into Codespaces."
Navigate to the template repository and select Use this template.
Name your repository, select your preferred privacy setting, and click Create repository from this template.
Navigate to the main page of the newly created repository. Under the repository name, use the Code drop-down menu, and select Open with Codespaces.
To create a codespace, click New codespace.
Once your codespace is created, your repository will be automatically cloned into it. Now you can run the application and launch it in a browser.
Since this example uses a Node.js project, start the application by entering
npm run devin the terminal. This command executes the
devscript in the package.json file and starts up the web application defined in the sample repository.
If you're following along with a different application type, enter the corresponding start command for that project.
When your application starts, the codespace recognizes the port the application is running on and displays a prompt to forward that port so you can connect to it.
Click Open in Browser to view your running application in a new tab.
Switch back to your codespace and open the
haikus.jsonfile by double-clicking it in the File Explorer.
textfield of the first haiku to personalize the application with your own haiku.
Go back to the running application tab in your browser and refresh to see your changes.
If you've closed the tab, open the Ports panel and click the Open in browser icon for the running port.
Now that you've made a few changes, you can use the integrated terminal or the source view to commit and push the changes back to the remote.
- In the Activity Bar, click the Source Control view.
- To stage your changes, click + next to the file you've changed, or next to Changes if you've changed multiple files and you want to stage them all.
- Type a commit message describing the change you've made.
- To commit your staged changes, click the check mark at the top the source control side bar.
You can push the changes you've made. This applies those changes to the upstream branch on the remote repository. You might want to do this if you're not yet ready to create a pull request, or if you prefer to create a pull request on GitHub.
- At the top of the side bar, click the ellipsis (...).
- In the drop-down menu, click Push.
Within a codespace, you have access to the Visual Studio Code Marketplace. For this example, you'll install an extension that alters the theme, but you can install any extension that is useful for your workflow.
In the left sidebar, click the Extensions icon.
In the search bar, enter
fairyflossand install the fairyfloss extension.
fairyflosstheme by selecting it from the list.
Changes you make to your editor setup in the current codespace, such as theme and keyboard bindings, are synced automatically via Settings Sync to any other codespaces you open and any instances of Visual Studio Code that are signed into your GitHub account.
You've successfully created, personalized, and run your first application within a codespace but there's so much more to explore! Here are some helpful resources for taking your next steps with Codespaces.
- Deep dive: This quickstart presented some of the features of Codespaces. The deep dive looks at these areas from a technical standpoint.
- Setting up your project for Codespaces. These guides provide information on setting up your project to use Codespaces with specific languages
- Configuring Codespaces for your project: This guide provides details on creating a custom configuration for Codespaces for your project.