How to Install and Configure the Snaplet VS Code Extension
What is the Snaplet VS Code Extension (VSCE)?
Snaplet makes software development more efficient and accurate by providing a seamless way to work with production-like data in a safe and compliant manner.
The Snaplet VSCE takes this a step further by integrating Snaplet's features directly into your VS Code environment.
This automates the process of branching your database when you branch your code, ensuring you always have a local development database seeded with fresh, production-realistic data.
Prerequisites
- VS Code installed.
- An active Snaplet account (this can be a free account).
Step-by-Step Installation and Configuration
Step 1: Open VS Code
- Launch VS Code on your computer.
Step 2: Access the Extension Marketplace
Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.
Use the search bar to search for "Snaplet".
(Optional - you can also install the VSCE directly from the Extension page via your browser here.)
Step 3: Install the Snaplet Extension
Locate the Snaplet extension in the search results.
Click the
Install
button next to the extension name.
Step 4: Link Your Snaplet Account
After installation, you'll find a Snaplet icon on the sidebar.
Click the
Connect to Snaplet
button to open the Snaplet panel.Allow VS Code to navigate to the Snaplet web app.
Select the appropriate project you want to use in the VS Code extension, and click
Connect
. If prompted, allow app.snaplet.dev to open VS Code.Allow the Snaplet VS Code extension to open the URI.
Your Snaplet VS Code extension is now associated with your Snaplet account, and installed. You just need to update your local development database environment to point to the Snaplet proxy.
Step 5: Tag Your Snapshots With main
The Snaplet extension looks for snapshots tagged with
main
, so ensure that your latest snapshot is tagged withmain
. You can tag your snapshots from within Snaplet Cloud by selecting a snapshot from the Snapshot list.You can optionally set all Snaplet scheduled snapshots to be automatically tagged with
main
from within the Project Settings view. This ensures your regularly scheduled snapshots are automatically used by the Snaplet VS Code extension.
Step 6: Configure Your Development Environment
- Go to your active project workspace.
- Change your local development database environment variable to point to
postgresql://snaplet@localhost:2345/snaplet
.
You're all done. Your Snaplet VSCE is now configured, and your local database will automatically branch when you switch branches in your code.
As always, if you have any issues, come join us on Discord for real-time support.