Last active
July 24, 2025 14:13
-
-
Save cameronapak/87709bf460ec9190dc22fded634ef0de to your computer and use it in GitHub Desktop.
Add bknd to Astro with a simple shadcn registry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://ui.shadcn.com/schema/registry-item.json", | |
| "name": "astro-integration", | |
| "type": "registry:block", | |
| "title": "bknd Astro Integration", | |
| "description": "Integration files for using bknd with Astro", | |
| "dependencies": [ | |
| "bknd@latest", | |
| "astro" | |
| ], | |
| "registryDependencies": [], | |
| "files": [ | |
| { | |
| "path": "registry/astro/src/bknd.config.ts", | |
| "content": "import type { AstroBkndConfig } from \"bknd/adapter/astro\";\n\nexport default {\n connection: {\n url: \":memory:\"\n }, \n} satisfies AstroBkndConfig;\n", | |
| "type": "registry:file", | |
| "target": "src/bknd.config.ts" | |
| }, | |
| { | |
| "path": "registry/astro/src/bknd.ts", | |
| "content": "import type { AstroGlobal } from \"astro\";\nimport { getApp as getBkndApp } from \"bknd/adapter/astro\";\nimport config from \"./bknd.config.ts\";\n\nexport { config };\n\nexport async function getApp() {\n return await getBkndApp(config);\n}\n\nexport async function getApi(\n astro: AstroGlobal,\n opts?: { mode: \"static\" } | { mode?: \"dynamic\"; verify?: boolean },\n) {\n const app = await getApp();\n if (opts?.mode !== \"static\" && opts?.verify) {\n const api = app.getApi({ headers: astro.request.headers });\n await api.verifyAuth();\n return api;\n }\n\n return app.getApi();\n}\n", | |
| "type": "registry:file", | |
| "target": "src/bknd.ts" | |
| }, | |
| { | |
| "path": "registry/astro/src/pages/admin/[...admin].astro", | |
| "content": "---\nimport { Admin } from \"bknd/ui\";\nimport \"bknd/dist/styles.css\";\nimport { getApi, config } from \"../../bknd\";\n\nconst api = await getApi(Astro, { verify: true });\nconst user = api.getUser();\n\nexport const prerender = false;\n---\n\n<html>\n <body>\n <Admin\n withProvider={{ user: user || undefined }}\n config={config}\n client:only\n />\n </body>\n</html>\n", | |
| "type": "registry:file", | |
| "target": "src/pages/admin/[...admin].astro" | |
| }, | |
| { | |
| "path": "registry/astro/src/pages/api/[...api].ts", | |
| "content": "import type { APIContext } from \"astro\";\nimport { serve } from \"bknd/adapter/astro\";\nimport { config } from \"../../bknd.ts\";\n\nexport const prerender = false;\nexport const ALL = serve<APIContext>(config);\n", | |
| "type": "registry:file", | |
| "target": "src/pages/api/[...api].ts" | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment