Connecting to GitHub
Draftbit’s GitHub Export lets you push your app’s generated source code straight to a repository you own, so it lives alongside the rest of your engineering workflow. The GitHub Export integration commits your app’s generated source code (React Native, Astro, Vite, or a backend variant, depending on your app) to a repository and branch you choose, whenever you trigger an export.
Before you start
Section titled “Before you start”You’ll need:
- A Draftbit app you’d like to connect, on a workspace with the Pro plan or higher — GitHub Export is a Pro-tier feature.
- A GitHub account with access to the destination repository.
- Permission to create a personal access token on that GitHub account (fine-grained tokens are recommended).
- An existing GitHub repository (empty or not) that you have push access to.
Set up the connection
Section titled “Set up the connection”-
Open your app in the AI Builder at next.draftbit.com.
-
Find the GitHub Export destination. There are two entry points:
- Export menu — click Export in the top toolbar, then select Setup next to the GitHub entry.
- Publish Destinations — open Publishing → Publish Destinations, alongside App Store Connect, Google Play Console, and Custom Domain.


From the Publishing page, click the Github Export card to open the Github Export Integration dialog, shown below.

-
Create a GitHub personal access token. Draftbit authenticates to your repository with a token scoped to Contents: Read and Write on the target repo. If your app’s generated code includes a
.github/workflowsdirectory, also grant Workflows: Read and write — otherwise the export will fail trying to write those files, even to a branch that doesn’t have them yet.- In the setup form, click the here link under the token field — this opens GitHub’s fine-grained token creation page.
- Give the token a recognizable name, for example
draftbit-export. - Under Repository access, select Only select repositories and choose your target repo.
- Under Permissions → Repository permissions, set Contents to Read and write (and Workflows to Read and write if your app’s generated code includes a
.github/workflowsdirectory). - Click Generate token, then copy it immediately — GitHub only shows it once.
-
Fill in the GitHub Export Integration form with your repository URL, branch name, and access token, then click Check Access. This confirms Draftbit can reach and read the repository — it only needs the repository URL and access token to enable, so you can check access before entering a branch name. It doesn’t push anything or confirm write access, so double-check the token was created with Contents: Read and Write as described above.
-
Click Save Configuration to store your repository, branch, and token. This saves the connection but doesn’t push any code by itself.
-
To push your code, open the Export menu in the top toolbar and click Commit next to the GitHub entry — this opens the export dialog. In the dialog, select Github from the Destination dropdown (it resets to blank each time the dialog opens, and Export stays disabled until a destination is chosen), then click Export to push your code to the configured branch. Larger apps can take a few minutes to push.
Field reference
Section titled “Field reference”| Field | What it’s for | Example |
|---|---|---|
| GitHub Repository URL (required) | The repository your exported code will be pushed to. A full URL or an org/repo slug both work — Draftbit validates it before saving. | https://github.com/username/repository |
| GitHub Branch Name (required) | The branch that receives each export. Use an existing branch, or a new name Draftbit can create on first push. Not required to check access, only to save. | main or draftbit-export |
| GitHub Access Token (required) | A personal access token with Contents: Read and Write permission on the target repository. Entered as a masked field. | github_pat_•••••••• |
Validation errors for missing fields appear inline as soon as you start filling in the form. Check Access only needs the repository URL and access token to enable — the branch name isn’t required until you save. Save Configuration stays disabled until all three fields are valid:

Best practices
Section titled “Best practices”- Scope your token tightly. Use a fine-grained token limited to the one repository you’re exporting to, with
Contents: Read and writeenabled (plusWorkflows: Read and writeif your app’s generated code includes a.github/workflowsdirectory) — avoid classic tokens with broad, account-wide access. - Use a dedicated branch you don’t hand-edit. Every export overwrites the entire contents of the target branch. Exporting to a branch like
draftbit-exportinstead ofmainkeeps generated pushes from clobbering code your team edits by hand. - Rotate tokens periodically. Set an expiration when you create the token and regenerate it periodically. Revoke it immediately from GitHub if it’s ever exposed.
- Verify before you save. Click Check Access first to confirm Draftbit can reach and read the repository — it only needs the repository URL and token, so you can do this before filling in a branch name. It doesn’t verify write access, so also double-check the token has
Contents: Read and Writebefore exporting.
Troubleshooting
Section titled “Troubleshooting”| You see this | Here’s what to do |
|---|---|
| ”Branch name is required” / “GitHub access token is required” | These inline messages appear as soon as you start filling in the form with a field still empty. Save Configuration stays disabled until all three fields are valid. Check Access only requires the repository URL and access token, so it can be used before a branch name is entered. |
| Check Access fails | Confirm the token hasn’t expired, that it grants Contents: Read and Write on the exact repository entered, and that the repository URL or slug is spelled correctly. Note that Check Access only recognizes a token typed into the field during the current session — if you’re reopening the dialog to update just the repository or branch, you’ll need to re-enter the token as well before Check Access will re-enable. |
| Repository URL rejected | Use either a full HTTPS URL (https://github.com/org/repo) or an org/repo slug, with or without a trailing .git — other formats (like SSH URLs) aren’t accepted. |
| Export seems stuck | Larger apps can take a few minutes to push. GitHub exports don’t appear on the Activity tab — check your repository’s commit history on the target branch to confirm the push completed. |
Can I reconfigure the connection later? Yes — reopen the GitHub Export card from Publish Destinations at any time to update the repository, branch, or token. Note that Check Access only recognizes a token entered during that session, so if you’re only updating the repository or branch, you’ll need to re-enter the token as well to re-verify access.
Does this replace the ZIP export? No, they’re independent. Download Project gives you a one-time ZIP; GitHub Export pushes commits to a live repository each time you export.
What exactly gets exported?
Your app’s generated source code — the same codebase you’d get from a manual ZIP export — pushed as a commit to the branch you configured, unless nothing has changed since your last export, in which case no new commit is created. Each export replaces the branch’s existing contents (aside from .git), so use a dedicated branch as described above.