apps/docs/deployment/self-hosting.mdx
Before you start, you'll need to gather several API keys and set up accounts with various services. This comprehensive guide will walk you through obtaining each required component.
Your enterprise deployment package is provided by the supermemory team and contains:
NEXT_PUBLIC_HOST_ID)Contact your supermemory enterprise representative to receive your deployment package.
yourcompany.workers.dev)Your CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN are now ready.
You'll need to provide a PostgreSQL connection string via the DATABASE_URL environment variable.
The database must:
Your connection string should follow this format:
postgresql://username:password@hostname:port/database
https://api.yourdomain.com)https://api.yourdomain.com/api/auth/callback/githubAUTH_GITHUB_ID and AUTH_GITHUB_SECREThttps://api.yourdomain.com/api/auth/callback/google to Authorized redirect URIsAUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET */}RESEND_API_KEYGOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRETMICROSOFT_CLIENT_ID and MICROSOFT_CLIENT_SECRETNOTION_CLIENT_ID and NOTION_CLIENT_SECRETExtract the deployment package provided by the supermemory team to your preferred directory:
# Extract the deployment package
$ unzip supermemory-enterprise-deployment.zip
$ cd supermemory-deployment
The deployment script reads all environment variables from your shell at runtime. We ship an example file that lists the full set supported by the worker.
# Copy the template and start editing
$ cp packages/alchemy/env.example .env
# Open the file in your editor of choice and fill in the blanks
$ $EDITOR .env
Below is a quick reference.
Required values are mandatory for a successful deploy – leave optional ones empty if you don't need the related feature.
| Name | Required? | Description |
|---|---|---|
NODE_ENV | ✅ | development, staging or production. |
NEXT_PUBLIC_HOST_ID | ✅ | Your unique Host ID provided by the supermemory team. |
BETTER_AUTH_SECRET | ✅ | Random 32-byte string – run openssl rand -base64 32. |
BETTER_AUTH_URL | ✅ | Public base URL for the API (no trailing /). Example: https://api.example.com. |
DATABASE_URL | ✅ | Postgres connection string (e.g. postgres://user:pass@host:5432/db). |
CLOUDFLARE_ACCOUNT_ID | ✅ | Your Cloudflare account ID. |
CLOUDFLARE_API_TOKEN | ✅ | Token created in Prerequisites. |
OPENAI_API_KEY | ✅ | Key from platform.openai.com. |
RESEND_API_KEY | ✅ | E-mail provider key if you plan to send e-mails. |
ANTHROPIC_API_KEY | Needed to use Claude models. | |
GEMINI_API_KEY | Key for Google Gemini models. | |
GROQ_API_KEY | Key for Groq models. | |
AUTH_GITHUB_ID / AUTH_GITHUB_SECRET | Enable GitHub OAuth login. | |
AUTH_GOOGLE_ID / AUTH_GOOGLE_SECRET | Enable Google OAuth login. | |
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET | Needed for Google Drive connector. | |
MICROSOFT_CLIENT_ID / MICROSOFT_CLIENT_SECRET | Needed for OneDrive connector. | |
NOTION_CLIENT_ID / NOTION_CLIENT_SECRET | Needed for Notion connector. | |
CLOUDFLARE_AI_GATEWAY_NAME / CLOUDFLARE_AI_GATEWAY_TOKEN | Only if you want to route requests through an AI Gateway. | |
SENTRY_DSN | If you use Sentry for error reporting. |
With your .env in place, run the deployment script:
# Run the deployment script provided in your package
$ bun ./deploy.ts
To update your supermemory deployment, follow the same process as the initial deployment described in the Deploy section above. You can reuse your existing .env file and add/remove any new environment variables as needed.