Deployment
Deploy LinkDen to Cloudflare Workers and Pages using Alchemy for automated infrastructure provisioning.
Deployment
LinkDen uses Alchemy to provision and deploy all Cloudflare resources -- Workers, Pages, D1 database, and KV namespaces -- with a single command.
Prerequisites
Before deploying, make sure you have:
- Completed the Installation and Configuration guides.
- Set
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDin your root.envfile. - Pushed your database migrations with
pnpm db:push.
Deploy to Cloudflare
Run the deploy command from the root of the monorepo:
pnpm cf:deployThis command:
- Builds the Next.js web app as a static export.
- Builds the Hono API server for Cloudflare Workers.
- Provisions all Cloudflare resources (D1 database, Workers, Pages).
- Uploads the static assets to Cloudflare Pages.
- Deploys the API worker.
The first deployment takes a few minutes while resources are created. Subsequent deploys are faster since Alchemy only updates what changed.
Custom Domain Setup
After the initial deployment, you can add a custom domain:
- Go to the Cloudflare dashboard.
- Navigate to Workers & Pages and find your LinkDen Pages project.
- Go to Custom Domains and add your domain.
- If your domain is already on Cloudflare, the DNS records are configured automatically.
- If your domain uses external DNS, add the CNAME record shown in the dashboard.
For detailed instructions, see Custom Domain Setup.
Verify the Deployment
After deploying:
- Visit your Pages URL (shown in the deploy output) to see the public link page.
- Navigate to
/adminand sign in with your Clerk account. - Check the admin dashboard to verify the API connection is working.
Tear Down Resources
If you need to remove all Cloudflare resources:
pnpm cf:destroyThis removes the Workers, Pages project, and D1 database. Use with caution -- this deletes all data.
Continuous Deployment
For automated deployments on every push, see the GitHub Actions workflow in .github/workflows/deploy.yml. It runs the CI pipeline first and then deploys on pushes to the main branch.
Troubleshooting
Build Fails
- Ensure all environment variables are set correctly.
- Run
pnpm buildlocally first to catch errors before deploying. - Check that your Cloudflare API token has the required permissions.
API Connection Issues
- Verify the
NEXT_PUBLIC_API_URLinapps/web/.envmatches your deployed Worker URL. - Check the Worker logs in the Cloudflare dashboard for errors.
Database Errors
- Run
pnpm db:pushto ensure the schema is up to date. - Check the D1 database in the Cloudflare dashboard for any issues.