Overview
Polaris IDE integrates with GitHub to import existing repositories and export your projects. This enables seamless collaboration and version control for your cloud IDE projects.GitHub integration uses the GitHub OAuth flow and requires a connected GitHub account.
Features
Import Repositories
Clone any public or private GitHub repository into Polaris IDE
Export Projects
Push your Polaris projects to new or existing GitHub repositories
OAuth Authentication
Secure authentication using GitHub OAuth with Stack Auth
Auto-create Repos
Automatically create repositories when exporting if they don’t exist
Setup
Connect GitHub Account
Navigate to Account Settings
Click your profile picture and select “Account Settings” or go to
/handler/account-settings.Authorize Polaris
You’ll be redirected to GitHub to authorize Polaris IDE. Click “Authorize” to grant access.
Required Permissions
Polaris IDE requests the following GitHub scopes:repo- Full control of private repositoriesread:user- Read user profile informationuser:email- Access user email addresses
Importing from GitHub
Import existing GitHub repositories into Polaris IDE:Using the Dashboard
Using the API
Import repositories programmatically using the GitHub import API:Import Implementation
The import process follows these steps (src/app/api/github/import/route.ts:68):
URL Parsing
Supported GitHub URL formats:src/lib/github.ts (parseGitHubUrl function)
Exporting to GitHub
Push your Polaris projects to GitHub repositories:Using the Project Menu
Configure Export
Repository URL:Options:
- Create if not exists (auto-create repository)
- Private repository (default: true)
- Repository description (optional)
- Commit message (default: “Update from Polaris”)
Using the API
Export projects programmatically:Export Implementation
The export process (src/app/api/github/export/route.ts:66):
Create Repository (Optional)
If
createIfNotExists is true and repo doesn’t exist:- Create the repository with specified settings
- Wait for GitHub to initialize the repo (2 second delay)
Push to GitHub
Use GitHub Contents API to create/update files:
- Create or update each file
- Batch commits where possible
- Handle file deletions if needed
Auto-create Repository
When exporting to a non-existent repository withcreateIfNotExists: true:
src/lib/github.ts (createRepository function)
GitHub API Integration
Polaris uses the Octokit REST client for GitHub API operations:Client Creation
Token Storage
GitHub OAuth tokens are stored securely in Stack Auth:Token Validation
Validate stored tokens before use:src/lib/github.ts
API Endpoints
POST /api/github/import
Import a GitHub repository into Polaris IDE. Request:200- Import successful400- Invalid request (bad URL)401- Unauthenticated403- GitHub not connected or project limit reached500- Import failed
src/app/api/github/import/route.ts:17
POST /api/github/export
Export a Polaris project to GitHub. Request:200- Export successful400- Invalid request401- Unauthenticated403- GitHub not connected404- Repository not found (when createIfNotExists is false)500- Export failed
src/app/api/github/export/route.ts:20
GET /api/github/status
Check GitHub connection status for the authenticated user. Response (Connected):src/app/api/github/status/route.ts:5
Import Status Tracking
Import operations update the project status in Convex:importing- Import in progresscompleted- Import successfulfailed- Import failed
convex/schema.ts:45
Export Status Tracking
Similar status tracking for exports:exporting- Export in progresscompleted- Export successfulfailed- Export failedcancelled- Export cancelled by user
convex/schema.ts:52
Rate Limiting
GitHub API has rate limits:- Authenticated requests: 5,000 requests/hour
- Unauthenticated requests: 60 requests/hour
Limitations
File Size Limits
File Size Limits
GitHub API limits file sizes:
- Maximum file size: 100 MB
- Recommended maximum: 10 MB
Repository Size
Repository Size
Very large repositories (1000+ files) may take several minutes to import. Consider importing only specific directories if possible.
Binary Files
Binary Files
Binary files are imported but may not be editable in the IDE. They are stored in Convex storage.
Git History
Git History
Import creates a new project with current files only. Git history is not preserved. Export creates new commits, it doesn’t preserve original commit history.
Troubleshooting
GitHub Not Connected Error
GitHub Not Connected Error
Issue: API returns “GitHub not connected”Solution:
- Go to Account Settings
- Check if GitHub is listed under Connected Accounts
- If not, click “Connect GitHub” and authorize
- If listed but still failing, disconnect and reconnect
Token Expired Error
Token Expired Error
Issue: Import/export fails with authentication errorSolution:
GitHub OAuth tokens can expire or be revoked. Reconnect your GitHub account:
- Go to Account Settings
- Disconnect GitHub
- Reconnect GitHub
Repository Not Found
Repository Not Found
Issue: Export fails with “repository not found”Solution:
- Ensure the repository URL is correct
- Check if the repository is private (requires proper access)
- Enable “Create if not exists” to auto-create the repository
Project Limit Reached
Project Limit Reached
Issue: Import fails with “project limit reached”Solution:
Free tier users are limited to 10 projects. Upgrade to Pro for unlimited projects:
- Go to Settings > Billing
- Click “Upgrade to Pro”
Security Considerations
GitHub tokens are stored securely in Stack Auth and never exposed to the client. All GitHub API operations happen server-side.
- OAuth tokens are encrypted at rest
- Tokens have limited scopes (only what’s necessary)
- All API requests are authenticated
- Rate limiting prevents abuse
- Path validation prevents malicious file operations
Next Steps
Stack Auth
Learn about authentication and account management
Convex Database
Understand how project data is stored