下のリンクから購入されると、当サイトに紹介料が支払われます。
Code snippet library and organizer — Commands, queries, and config blocks you reuse, searchable by language and tag, with an API and MCP for
GitHub Gist のオープンソース代替
Code snippet library and organizer — Commands, queries, and config blocks you reuse, searchable by language and tag, with an API and MCP for other tools.
READMEGitHub の jordan-dalby/ByteStash
ByteStash is a self-hosted web application designed to store, organise, and manage your code snippets efficiently. With support for creating, editing, and filtering snippets, ByteStash helps you keep track of your code in one secure place.
Check out the ByteStash demo powered by PikaPods!
Username: demo
Password: demodemo
ByteStash is now on the Unraid App Store! Install it from there.
Also available on PikaPods for 1-click install from $1/month.
ByteStash can also be hosted manually via the docker-compose file:
services:
bytestash:
image: "ghcr.io/jordan-dalby/bytestash:latest"
restart: always
volumes:
- /your/snippet/path:/data/snippets
ports:
- "5000:5000"
environment:
# See https://github.com/jordan-dalby/ByteStash/wiki/FAQ#environment-variables
#ALLOWED_HOSTS: localhost,my.domain.com,my.domain.net
BASE_PATH: ""
TOKEN_EXPIRY: 24h
ALLOW_NEW_ACCOUNTS: "true"
DEBUG: "true"
DISABLE_ACCOUNTS: "false"
DISABLE_INTERNAL_ACCOUNTS: "false"
# See https://github.com/jordan-dalby/ByteStash/wiki/Single-Sign%E2%80%90on-Setup for more info
OIDC_ENABLED: "false"
OIDC_DISPLAY_NAME: ""
OIDC_ISSUER_URL: ""
OIDC_CLIENT_ID: ""
OIDC_CLIENT_SECRET: ""
OIDC_SCOPES: ""
# The address you open ByteStash at, e.g. https://bytestash.example.com
PUBLIC_URL: ""
New accounts are never admins. To make your first admin, sign up (or sign in with single sign-on) as usual, then run this inside the container:
# Docker Compose, using the service name from your compose file
# ("bytestash" in the example above, "server" in the repo's docker-compose.yaml)
docker compose exec bytestash node src/scripts/admin.js grant <username>
# Plain Docker
docker exec -it <container-name> node src/scripts/admin.js grant <username>
# Kubernetes / Helm
kubectl exec -it deploy/<deployment-name> -- node src/scripts/admin.js grant <username>
The change applies straight away, no restart needed. Sign out and back in to see the admin panel. After that you can add or remove admins from Admin > Users in the web UI, or with the same script:
node src/scripts/admin.js list # show all admins
node src/scripts/admin.js revoke <username> # remove admin access
If you don't need open sign-ups, set ALLOW_NEW_ACCOUNTS to false once your accounts exist.
Upgrading from an older version? The
ADMIN_USERNAMESenvironment variable has been removed and is ignored, so accounts listed in it are no longer admins. Run thegrantcommand above for each account that should be an admin, then deleteADMIN_USERNAMESfrom your configuration. If your config hadADMIN_USERNAMES=admin(the old default) and sign-ups were open, check that you created theadminaccount yourself before you grant it anything.
ByteStash supports any OpenID Connect provider (Authentik, Authelia, Keycloak, Pocket ID, ...).
Register these two URLs in your provider, replacing https://bytestash.example.com with your
PUBLIC_URL (including BASE_PATH if you use one):
https://bytestash.example.com/api/auth/oidc/callbackhttps://bytestash.example.com/auth/logout_callback| Variable | Description |
|---|---|
OIDC_ISSUER_URL | The issuer URL of your provider, e.g. https://auth.example.com/application/o/bytestash/ for Authentik or https://id.example.com for Pocket ID. |
OIDC_CLIENT_ID, OIDC_CLIENT_SECRET | The client credentials from your provider. Leave the secret empty for a public client. |
OIDC_SCOPES | Defaults to openid profile email. openid is always requested. |
PUBLIC_URL | The URL users open ByteStash at. When set, the redirect URLs are built from it instead of the X-Forwarded-* headers of your reverse proxy. |
OIDC_TOKEN_ENDPOINT_AUTH_METHOD | client_secret_post, client_secret_basic or none. Detected automatically, only set it if your provider insists on one. |
On startup ByteStash logs whether it could reach the provider, and failed logins log the reason
(and show it on the login page). If your provider uses a certificate from your own CA, mount the CA
certificate into the container and point NODE_EXTRA_CA_CERTS at it, e.g.
NODE_EXTRA_CA_CERTS: /certs/my-ca.crt.
ByteStash stores everything in a SQLite database under /data/snippets by default. To use
PostgreSQL instead, point ByteStash at an existing database with either a connection string or
the individual settings. The tables are created automatically on first start.
environment:
DATABASE_URL: "postgres://bytestash:password@postgres:5432/bytestash"
# or
POSTGRES_HOST: postgres
POSTGRES_PORT: "5432"
POSTGRES_USER: bytestash
POSTGRES_PASSWORD: password
POSTGRES_DB: bytestash
| Variable | Description |
|---|---|
DATABASE_URL / DATABASE_URL_FILE | PostgreSQL connection string, or a file containing it (Docker secrets). |
POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB | Used when DATABASE_URL is not set. Port defaults to 5432, user and database to bytestash. POSTGRES_PASSWORD_FILE is also supported. |
POSTGRES_SSL | true to require TLS, no-verify to skip certificate verification, false to disable. |
MIGRATE_SQLITE_TO_POSTGRES | true copies the existing SQLite data into PostgreSQL on startup. Only runs while PostgreSQL is empty, so it is safe to leave enabled. |
If neither DATABASE_URL nor POSTGRES_HOST is set, ByteStash keeps using SQLite. Keep the
/data/snippets volume mounted either way: it holds the generated JWT secret (unless
JWT_SECRET is set) and the SQLite file used by the migration.
/data/snippets volume.MIGRATE_SQLITE_TO_POSTGRES: "true" and restart
the container. Users, snippets, shares, API keys and settings are copied across with their
existing IDs, so share links and API keys keep working.The migration can also be run by hand once PostgreSQL is configured:
docker compose exec bytestash node src/scripts/migrateToPostgres.js
# replace whatever is already in PostgreSQL with the SQLite data
docker compose exec bytestash node src/scripts/migrateToPostgres.js --force
Changes made while running on PostgreSQL are not copied back to SQLite.
Once the server is running you can explore the API via Swagger UI. Open
/api-docs in your browser to view the documentation for all endpoints.
ByteStash exposes a remote Model Context Protocol endpoint so AI assistants such as Claude (desktop & web), OpenAI/ChatGPT and Perplexity can search, read and manage your snippets directly.
https://<your-host>/mcp (or https://<your-host><BASE_PATH>/mcp when a
base path is configured). It is served on the same host/port as the app, so nothing extra
needs to be exposed in your deployment.Authorization: Bearer <api-key>
(or the x-api-key header). The MCP tools only ever access snippets owned by that key.list_snippets, get_snippet, create_snippet, update_snippet, delete_snippet,
list_metadata.
claude_desktop_config.json):
{
"mcpServers": {
"bytestash": {
"type": "http",
"url": "https://your-host/mcp",
"headers": { "Authorization": "Bearer YOUR_API_KEY" }
}
}
}
https://your-host/mcp and supply the Authorization: Bearer YOUR_API_KEY header.{
"type": "mcp",
"server_label": "bytestash",
"server_url": "https://your-host/mcp",
"headers": { "Authorization": "Bearer YOUR_API_KEY" }
}
Authorization header.The endpoint requires HTTPS for remote clients — terminate TLS at your reverse proxy/ingress as you already do for the web UI.
Contributions are welcome! Please submit a pull request or open an issue for any improvements or bug fixes.
To add phrases for a new language, follow these steps. Example for fr locale:
Locale enum in the client/src/i18n/types.ts filelocales array in the client/i18next.config.ts filecd client && npm run i18n:extract__TRANSLATE_ME__ lines with the desired phrasesclient/src/i18n/resources/fr.tsclient/src/i18n/resources/index.tsnpm run devcd client && npm run startActively maintained (recent upstream activity).
GitHub からの最終更新:4 時間前
GitHub の数値は1日に数回更新されます。
ログイン または アカウントを作成 するとコメントできます。
まだコメントはありません。最初のコメントを書いてみませんか。
アピールしましょう。順位と評価が載ったライブカードで、自動的に更新されます。
小さいほうがよければ、次を追加: ?style=flat