create-sidekick-app 0.0.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/LICENSE.md +202 -0
  2. package/NOTICE +27 -0
  3. package/README.md +29 -2
  4. package/dist/index.js +59 -0
  5. package/package.json +65 -4
  6. package/template/base/ai-chat/.env.example +6 -0
  7. package/template/base/ai-chat/.prettierignore +2 -0
  8. package/template/base/ai-chat/.prettierrc.json +5 -0
  9. package/template/base/ai-chat/README.md +38 -0
  10. package/template/base/ai-chat/_gitignore +41 -0
  11. package/template/base/ai-chat/components.json +23 -0
  12. package/template/base/ai-chat/next.config.ts +5 -0
  13. package/template/base/ai-chat/package.json +61 -0
  14. package/template/base/ai-chat/postcss.config.mjs +5 -0
  15. package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
  16. package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
  17. package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
  18. package/template/base/ai-chat/src/app/globals.css +124 -0
  19. package/template/base/ai-chat/src/app/layout.tsx +34 -0
  20. package/template/base/ai-chat/src/app/page.tsx +6 -0
  21. package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
  22. package/template/base/ai-chat/src/components/Chat.tsx +228 -0
  23. package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
  24. package/template/base/ai-chat/src/components/Login.tsx +163 -0
  25. package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
  26. package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
  27. package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
  28. package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
  29. package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
  30. package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
  31. package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
  32. package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
  33. package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
  34. package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
  35. package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
  36. package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
  37. package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
  38. package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
  39. package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
  40. package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
  41. package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
  42. package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
  43. package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
  44. package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
  45. package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
  46. package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
  47. package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
  48. package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
  49. package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
  50. package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
  51. package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
  52. package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
  53. package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
  54. package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
  55. package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
  56. package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
  57. package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
  58. package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
  59. package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
  60. package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
  61. package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
  62. package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
  63. package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
  64. package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
  65. package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
  66. package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
  67. package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
  68. package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
  69. package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
  70. package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
  71. package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
  72. package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
  73. package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
  74. package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
  75. package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
  76. package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
  77. package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
  78. package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
  79. package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
  80. package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
  81. package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
  82. package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
  83. package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
  84. package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
  85. package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
  86. package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
  87. package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
  88. package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
  89. package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
  90. package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
  91. package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
  92. package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
  93. package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
  94. package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
  95. package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
  96. package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
  97. package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
  98. package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
  99. package/template/base/ai-chat/src/instant.perms.ts +34 -0
  100. package/template/base/ai-chat/src/instant.schema.ts +107 -0
  101. package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
  102. package/template/base/ai-chat/src/lib/db.ts +8 -0
  103. package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
  104. package/template/base/ai-chat/src/lib/utils.ts +6 -0
  105. package/template/base/ai-chat/tsconfig.json +33 -0
  106. package/template/base/bun-react/.env.example +2 -0
  107. package/template/base/bun-react/README.md +12 -0
  108. package/template/base/bun-react/_gitignore +34 -0
  109. package/template/base/bun-react/bun-env.d.ts +17 -0
  110. package/template/base/bun-react/bunfig.toml +4 -0
  111. package/template/base/bun-react/package.json +22 -0
  112. package/template/base/bun-react/src/App.tsx +168 -0
  113. package/template/base/bun-react/src/frontend.tsx +20 -0
  114. package/template/base/bun-react/src/getUnusedPort.ts +32 -0
  115. package/template/base/bun-react/src/index.css +25 -0
  116. package/template/base/bun-react/src/index.html +13 -0
  117. package/template/base/bun-react/src/index.ts +21 -0
  118. package/template/base/bun-react/src/instant.perms.ts +24 -0
  119. package/template/base/bun-react/src/instant.schema.ts +46 -0
  120. package/template/base/bun-react/src/lib/db.ts +8 -0
  121. package/template/base/bun-react/src/logo.svg +1 -0
  122. package/template/base/bun-react/tsconfig.json +36 -0
  123. package/template/base/expo/.env.example +2 -0
  124. package/template/base/expo/README.md +18 -0
  125. package/template/base/expo/_gitignore +41 -0
  126. package/template/base/expo/app/+not-found.tsx +16 -0
  127. package/template/base/expo/app/_layout.tsx +37 -0
  128. package/template/base/expo/app/index.tsx +64 -0
  129. package/template/base/expo/app.json +42 -0
  130. package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
  131. package/template/base/expo/assets/images/adaptive-icon.png +0 -0
  132. package/template/base/expo/assets/images/favicon.png +0 -0
  133. package/template/base/expo/assets/images/icon.png +0 -0
  134. package/template/base/expo/assets/images/partial-react-logo.png +0 -0
  135. package/template/base/expo/assets/images/react-logo.png +0 -0
  136. package/template/base/expo/assets/images/react-logo@2x.png +0 -0
  137. package/template/base/expo/assets/images/react-logo@3x.png +0 -0
  138. package/template/base/expo/assets/images/splash-icon.png +0 -0
  139. package/template/base/expo/babel.config.js +12 -0
  140. package/template/base/expo/constants/Colors.ts +26 -0
  141. package/template/base/expo/eslint.config.js +10 -0
  142. package/template/base/expo/global.css +3 -0
  143. package/template/base/expo/hooks/useColorScheme.ts +1 -0
  144. package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
  145. package/template/base/expo/hooks/useThemeColor.ts +21 -0
  146. package/template/base/expo/instant.perms.ts +24 -0
  147. package/template/base/expo/instant.schema.ts +44 -0
  148. package/template/base/expo/lib/db.ts +7 -0
  149. package/template/base/expo/metro.config.js +6 -0
  150. package/template/base/expo/nativewind-env.d.ts +1 -0
  151. package/template/base/expo/package.json +57 -0
  152. package/template/base/expo/scripts/reset-project.js +112 -0
  153. package/template/base/expo/tailwind.config.js +9 -0
  154. package/template/base/expo/tsconfig.json +18 -0
  155. package/template/base/next-js-app-dir/.env.example +2 -0
  156. package/template/base/next-js-app-dir/README.md +18 -0
  157. package/template/base/next-js-app-dir/_gitignore +41 -0
  158. package/template/base/next-js-app-dir/next.config.ts +7 -0
  159. package/template/base/next-js-app-dir/package.json +27 -0
  160. package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
  161. package/template/base/next-js-app-dir/public/file.svg +1 -0
  162. package/template/base/next-js-app-dir/public/globe.svg +1 -0
  163. package/template/base/next-js-app-dir/public/next.svg +1 -0
  164. package/template/base/next-js-app-dir/public/vercel.svg +1 -0
  165. package/template/base/next-js-app-dir/public/window.svg +1 -0
  166. package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
  167. package/template/base/next-js-app-dir/src/app/globals.css +26 -0
  168. package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
  169. package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
  170. package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
  171. package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
  172. package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
  173. package/template/base/next-js-app-dir/tsconfig.json +41 -0
  174. package/template/base/solidjs-vite/README.md +15 -0
  175. package/template/base/solidjs-vite/_gitignore +25 -0
  176. package/template/base/solidjs-vite/index.html +15 -0
  177. package/template/base/solidjs-vite/package.json +25 -0
  178. package/template/base/solidjs-vite/src/App.tsx +171 -0
  179. package/template/base/solidjs-vite/src/index.css +25 -0
  180. package/template/base/solidjs-vite/src/index.tsx +16 -0
  181. package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
  182. package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
  183. package/template/base/solidjs-vite/src/lib/db.ts +8 -0
  184. package/template/base/solidjs-vite/tsconfig.json +20 -0
  185. package/template/base/solidjs-vite/vite.config.ts +11 -0
  186. package/template/base/sveltekit/README.md +15 -0
  187. package/template/base/sveltekit/_gitignore +26 -0
  188. package/template/base/sveltekit/package.json +25 -0
  189. package/template/base/sveltekit/src/app.css +25 -0
  190. package/template/base/sveltekit/src/app.html +11 -0
  191. package/template/base/sveltekit/src/instant.perms.ts +24 -0
  192. package/template/base/sveltekit/src/instant.schema.ts +46 -0
  193. package/template/base/sveltekit/src/lib/db.ts +8 -0
  194. package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
  195. package/template/base/sveltekit/src/routes/+page.svelte +236 -0
  196. package/template/base/sveltekit/src/routes/+page.ts +1 -0
  197. package/template/base/sveltekit/svelte.config.js +10 -0
  198. package/template/base/sveltekit/tsconfig.json +14 -0
  199. package/template/base/sveltekit/vite.config.ts +7 -0
  200. package/template/base/tanstack-start/.cta.json +12 -0
  201. package/template/base/tanstack-start/README.md +17 -0
  202. package/template/base/tanstack-start/_gitignore +13 -0
  203. package/template/base/tanstack-start/package.json +43 -0
  204. package/template/base/tanstack-start/public/favicon.ico +0 -0
  205. package/template/base/tanstack-start/public/logo192.png +0 -0
  206. package/template/base/tanstack-start/public/logo512.png +0 -0
  207. package/template/base/tanstack-start/public/manifest.json +25 -0
  208. package/template/base/tanstack-start/public/robots.txt +3 -0
  209. package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
  210. package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
  211. package/template/base/tanstack-start/src/components/Header.tsx +21 -0
  212. package/template/base/tanstack-start/src/instant.perms.ts +24 -0
  213. package/template/base/tanstack-start/src/instant.schema.ts +50 -0
  214. package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
  215. package/template/base/tanstack-start/src/lib/db.ts +9 -0
  216. package/template/base/tanstack-start/src/logo.svg +12 -0
  217. package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
  218. package/template/base/tanstack-start/src/router.tsx +22 -0
  219. package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
  220. package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
  221. package/template/base/tanstack-start/src/routes/index.tsx +238 -0
  222. package/template/base/tanstack-start/src/routes/login.tsx +140 -0
  223. package/template/base/tanstack-start/src/styles.css +18 -0
  224. package/template/base/tanstack-start/tsconfig.json +28 -0
  225. package/template/base/tanstack-start/vite.config.ts +33 -0
  226. package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
  227. package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
  228. package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
  229. package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
  230. package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
  231. package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
  232. package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
  233. package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
  234. package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
  235. package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
  236. package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
  237. package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
  238. package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
  239. package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
  240. package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
  241. package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
  242. package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
  243. package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
  244. package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
  245. package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
  246. package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
  247. package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
  248. package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
  249. package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
  250. package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
  251. package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
  252. package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
  253. package/template/base/vite-react/README.md +16 -0
  254. package/template/base/vite-react/_gitignore +26 -0
  255. package/template/base/vite-react/eslint.config.js +23 -0
  256. package/template/base/vite-react/index.html +13 -0
  257. package/template/base/vite-react/package.json +35 -0
  258. package/template/base/vite-react/public/favicon.svg +1 -0
  259. package/template/base/vite-react/src/App.tsx +167 -0
  260. package/template/base/vite-react/src/index.css +1 -0
  261. package/template/base/vite-react/src/instant.perms.ts +24 -0
  262. package/template/base/vite-react/src/instant.schema.ts +51 -0
  263. package/template/base/vite-react/src/lib/db.ts +8 -0
  264. package/template/base/vite-react/src/main.tsx +10 -0
  265. package/template/base/vite-react/tsconfig.app.json +25 -0
  266. package/template/base/vite-react/tsconfig.json +7 -0
  267. package/template/base/vite-react/tsconfig.node.json +24 -0
  268. package/template/base/vite-react/vite.config.ts +8 -0
  269. package/template/base/vite-vanilla/.env.example +2 -0
  270. package/template/base/vite-vanilla/README.md +17 -0
  271. package/template/base/vite-vanilla/_gitignore +25 -0
  272. package/template/base/vite-vanilla/index.html +13 -0
  273. package/template/base/vite-vanilla/package.json +20 -0
  274. package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
  275. package/template/base/vite-vanilla/public/vite.svg +1 -0
  276. package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
  277. package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
  278. package/template/base/vite-vanilla/src/lib/db.ts +11 -0
  279. package/template/base/vite-vanilla/src/main.ts +242 -0
  280. package/template/base/vite-vanilla/src/style.css +96 -0
  281. package/template/base/vite-vanilla/src/typescript.svg +1 -0
  282. package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
  283. package/template/base/vite-vanilla/tsconfig.json +24 -0
  284. package/template/base/vue-vite/README.md +15 -0
  285. package/template/base/vue-vite/_gitignore +43 -0
  286. package/template/base/vue-vite/env.d.ts +1 -0
  287. package/template/base/vue-vite/index.html +12 -0
  288. package/template/base/vue-vite/package.json +34 -0
  289. package/template/base/vue-vite/src/App.vue +238 -0
  290. package/template/base/vue-vite/src/assets/main.css +25 -0
  291. package/template/base/vue-vite/src/instant.perms.ts +24 -0
  292. package/template/base/vue-vite/src/instant.schema.ts +46 -0
  293. package/template/base/vue-vite/src/lib/db.ts +8 -0
  294. package/template/base/vue-vite/src/main.ts +6 -0
  295. package/template/base/vue-vite/tsconfig.app.json +15 -0
  296. package/template/base/vue-vite/tsconfig.json +11 -0
  297. package/template/base/vue-vite/tsconfig.node.json +27 -0
  298. package/template/base/vue-vite/vite.config.ts +16 -0
  299. package/template/rules/AGENTS.md +450 -0
@@ -0,0 +1,450 @@
1
+ Act as a world-class senior frontend engineer with deep expertise in SidekickDB
2
+ and UI/UX design. Your primary goal is to generate complete and functional apps
3
+ with excellent visual aesthetics using SidekickDB as the backend.
4
+
5
+ # About SidekickDB
6
+
7
+ SidekickDB is a client-side database (Modern Firebase) with built-in queries, transactions, auth, permissions, storage, real-time, and offline support.
8
+
9
+ # SidekickDB SDKs
10
+
11
+ SidekickDB provides client-side SDKs and server-side SDKs:
12
+
13
+ - `@sidekickdb/core` --- vanilla JS
14
+ - `@sidekickdb/react` --- React
15
+ - `@sidekickdb/react-native` --- React Native / Expo
16
+ - `@sidekickdb/solidjs` --- SolidJS
17
+ - `@sidekickdb/svelte` --- Svelte
18
+ - `@sidekickdb/vue` --- Vue
19
+ - `@sidekickdb/admin` --- JS/TS backend SDK
20
+
21
+ When installing, always check what package manager the project uses (npm, pnpm,
22
+ bun) first and then install the latest version of the SidekickDB SDK. If working in
23
+ React use Next and Tailwind unless specified otherwise.
24
+
25
+ # Managing SidekickDB Apps
26
+
27
+ ## Prerequisites
28
+
29
+ Look for `instant.schema.ts` and `instant.perms.ts`. These define the schema and permissions.
30
+ Look for an app id and admin token in `.env` or another env file.
31
+
32
+ SidekickDB has no default server. The CLI reads the server URL from `apiURI` in
33
+ `sidekick.config.ts` or `instant.config.ts` (the first one found wins), or from
34
+ the `SIDEKICK_CLI_API_URI` environment variable, which wins over both. `login`
35
+ also needs the dashboard URL: `dashURI` in the same file, or
36
+ `SIDEKICK_CLI_DASH_URI`. If they are not set, ask the user for their URLs.
37
+
38
+ If schema/perm files exist but the app id/admin token are missing, ask the user where to find them or whether to create a new app.
39
+
40
+ To create a new app:
41
+
42
+ ```bash
43
+ npx @sidekickdb/cli init-without-files --title <APP_NAME>
44
+ ```
45
+
46
+ This outputs an app id and admin token. Store them in an env file.
47
+
48
+ If you get an error related to not being logged in tell the user to:
49
+
50
+ - Sign up or log in on the dashboard of their SidekickDB server
51
+ - Then run `npx @sidekickdb/cli login` to authenticate the CLI
52
+ - Then re-run the init command
53
+
54
+ If you have an app id/admin token but no schema/perm files, pull them:
55
+
56
+ ```bash
57
+ npx @sidekickdb/cli pull --yes
58
+ ```
59
+
60
+ ## Schema changes
61
+
62
+ Edit `instant.schema.ts`, then push:
63
+
64
+ ```bash
65
+ npx @sidekickdb/cli push schema --yes
66
+ ```
67
+
68
+ New fields = additions; missing fields = deletions.
69
+
70
+ To rename fields:
71
+
72
+ ```bash
73
+ npx @sidekickdb/cli push schema --rename 'posts.author:posts.creator stores.owner:stores.manager' --yes
74
+ ```
75
+
76
+ ## Permission changes
77
+
78
+ Edit `instant.perms.ts`, then push:
79
+
80
+ ```bash
81
+ npx @sidekickdb/cli push perms --yes
82
+ ```
83
+
84
+ # CRITICAL Query Guidelines
85
+
86
+ CRITICAL: When using React make sure to follow the rules of hooks. Remember, you can't have hooks show up conditionally.
87
+
88
+ CRITICAL: You MUST index any field you want to filter or order by in the schema. If you do not, you will get an error when you try to filter or order by it.
89
+
90
+ Here is how ordering works:
91
+
92
+ ```text
93
+ Ordering: order: { field: 'asc' | 'desc' }
94
+
95
+ Example: $: { order: { dueDate: 'asc' } }
96
+
97
+ Notes: - Field must be indexed + typed in schema
98
+ - Cannot order by nested attributes (e.g. 'owner.name')
99
+ ```
100
+
101
+ CRITICAL: Here is a concise summary of the `where` operator map which defines all the filtering options you can use with SidekickDB queries to narrow results based on field values, comparisons, arrays, text patterns, and logical conditions.
102
+
103
+ ```text
104
+ Equality: { field: value }
105
+
106
+ Inequality: { field: { $ne: value } }
107
+
108
+ Null checks: { field: { $isNull: true | false } }
109
+
110
+ Comparison: $gt, $lt, $gte, $lte (indexed + typed fields only)
111
+
112
+ Sets: { field: { $in: [v1, v2] } }
113
+
114
+ Substring: { field: { $like: 'Get%' } } // case-sensitive
115
+ { field: { $ilike: '%get%' } } // case-insensitive
116
+
117
+ Logic: and: [ {...}, {...} ]
118
+ or: [ {...}, {...} ]
119
+
120
+ Nested fields: 'relation.field': value
121
+ ```
122
+
123
+ CRITICAL: The operator map above is the full set of `where` filters SidekickDB
124
+ supports right now. There is no `$exists`, `$nin`, or `$regex`. And `$like` and
125
+ `$ilike` are what you use for `startsWith` / `endsWith` / `includes`.
126
+
127
+ CRITICAL: Pagination keys (`limit`, `offset`, `first`, `after`, `last`, `before`) only work on top-level namespaces. DO NOT use them on nested relations or else you will get an error.
128
+
129
+ CRITICAL: If you are unsure how something works in SidekickDB you fetch the relevant urls in the documentation to learn more.
130
+
131
+ # CRITICAL Permission Guidelines
132
+
133
+ Below are some CRITICAL guidelines for writing permissions in SidekickDB.
134
+
135
+ ## `data.ref`
136
+
137
+ - Use `data.ref("<path.to.attr>")` for linked attributes.
138
+ - Always returns a **list**.
139
+ - Must end with an **attribute**.
140
+
141
+ **Correct**
142
+
143
+ ```cel
144
+ auth.id in data.ref('post.author.id') // auth.id in list of author ids
145
+ data.ref('owner.id') == [] // there is no owner
146
+ ```
147
+
148
+ **Errors**
149
+
150
+ ```cel
151
+ auth.id in data.post.author.id
152
+ auth.id in data.ref('author')
153
+ data.ref('admins.id') == auth.id
154
+ auth.id == data.ref('owner.id')
155
+ data.ref('owner.id') == null
156
+ data.ref('owner.id').length > 0
157
+ ```
158
+
159
+ ## `auth.ref`
160
+
161
+ - Same as `data.ref` but path must start with `$user`.
162
+ - Returns a list.
163
+
164
+ **Correct**
165
+
166
+ ```cel
167
+ 'admin' in auth.ref('$user.role.type')
168
+ auth.ref('$user.role.type')[0] == 'admin'
169
+ ```
170
+
171
+ **Errors**
172
+
173
+ ```cel
174
+ auth.ref('role.type')
175
+ auth.ref('$user.role.type') == 'admin'
176
+ ```
177
+
178
+ ## Unsupported
179
+
180
+ ```cel
181
+ newData.ref('x')
182
+ data.ref(someVar + '.members.id')
183
+ ```
184
+
185
+ ## $users Permissions
186
+
187
+ - Default `view` permission is `auth.id == data.id`
188
+ - Default `update` and `delete` permissions is false
189
+ - Default `create` permission is true (anyone can sign up)
190
+ - Can override `view`, `update`, and `create`
191
+ - Cannot override `delete`
192
+ - The `create` rule runs during auth signup flows (not via `transact`). Use it to restrict signups or validate `extraFields`.
193
+ - `extraFields` require an explicit `create` rule. Without one, signup is blocked to prevent unvalidated writes.
194
+
195
+ ## $files Permissions
196
+
197
+ - Default permissions are all false. Override as needed to allow access.
198
+ - `data.ref` does not work for `$files` permissions.
199
+ - Use `data.path.startsWith(...)` or `data.path.endsWith(...)` to write
200
+ path-based rules.
201
+
202
+ ## Field-level Permissions
203
+
204
+ Restrict access to specific fields while keeping the entity public:
205
+
206
+ ```json
207
+ {
208
+ "$users": {
209
+ "allow": {
210
+ "view": "true"
211
+ },
212
+ "fields": {
213
+ "email": "auth.id == data.id"
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ Notes:
220
+
221
+ - Field rules override entity-level `view` for that field
222
+ - Useful for hiding sensitive data (emails, phone numbers) on public entities
223
+
224
+ # CRITICAL Storage Guidelines
225
+
226
+ CRITICAL: If an app displays images or files, use SidekickDB Storage. Do not store
227
+ URLs as string attributes on your entities. This includes seed scripts: do not
228
+ use placeholder image URLs (e.g. picsum.photos) as string attributes to fake
229
+ file support.
230
+
231
+ Uploads auto-create `$files` entities. Link them to your data via the schema,
232
+ then query through the relationship to get URLs.
233
+
234
+ CRITICAL: You MUST include `$files` in your schema entities if you use Storage.
235
+
236
+ CRITICAL: `$files` entities can only be created via `db.storage.uploadFile`. You
237
+ cannot create `$files` via `db.transact`, and you cannot set `url` via transactions.
238
+
239
+ ```tsx
240
+ entities: {
241
+ $files: i.entity({
242
+ path: i.string().unique().indexed(),
243
+ url: i.string(),
244
+ }),
245
+ posts: i.entity({
246
+ caption: i.string(),
247
+ }),
248
+ },
249
+ links: {
250
+ postImage: {
251
+ forward: { on: "posts", has: "one", label: "image" },
252
+ reverse: { on: "$files", has: "many", label: "posts" },
253
+ },
254
+ }
255
+
256
+ // Upload and link the returned file ID to your entity
257
+ const postId = id();
258
+ const { data } = await db.storage.uploadFile(`posts/${postId}/${file.name}`, file);
259
+ db.transact(
260
+ db.tx.posts[postId].update({ caption }).link({ image: data.id })
261
+ );
262
+
263
+ // Query through the relationship to get the URL
264
+ const { data } = db.useQuery({ posts: { image: {} } });
265
+ <img src={post.image.url} />
266
+ ```
267
+
268
+ # CRITICAL Rooms Guidelines
269
+
270
+ CRITICAL: Hooks for presence and topics live on `db.rooms` and take the room as the first arg. The room object itself has no `usePresence` or `publishPresence` methods.
271
+
272
+ Rooms host two ephemeral primitives: presence (cursor positions, who's online) and topics (live reactions). Use them only for data that should NOT persist. Persisted data via `transact` already syncs in real-time to all subscribed clients, so reach for rooms only when the data is intentionally ephemeral.
273
+
274
+ ## Presence
275
+
276
+ Each peer publishes a presence object readable by all other peers in the room. Retained for the connection and cleaned up automatically on disconnect.
277
+
278
+ ```tsx
279
+ const room = db.room('chat', 'main');
280
+ const { user, peers, publishPresence } = db.rooms.usePresence(room, {
281
+ initialPresence: { x: 0, y: 0 },
282
+ });
283
+ // peers is keyed by peerId, not an array. Use Object.values(peers) to iterate
284
+ publishPresence({ x: 50, y: 50 });
285
+ ```
286
+
287
+ ## Topics
288
+
289
+ Topic payloads aren't retained. Peers only see events fired while they're listening.
290
+
291
+ ```tsx
292
+ const room = db.room('chat', 'main');
293
+
294
+ const publishEmoji = db.rooms.usePublishTopic(room, 'emoji');
295
+ publishEmoji({ name: 'fire' });
296
+
297
+ db.rooms.useTopicEffect(room, 'emoji', (payload) => {
298
+ animateEmoji(payload.name);
299
+ });
300
+ ```
301
+
302
+ # Best Practices
303
+
304
+ ## Pass `schema` when initializing SidekickDB
305
+
306
+ Always pass `schema` when initializing SidekickDB to get type safety for queries and transactions
307
+
308
+ If the project already calls `init` from the SDK you need (for example in
309
+ `src/lib/db.ts`), import its exported database instead of calling `init` again.
310
+
311
+ Every `init` also needs `apiURI`, the URL of the user's SidekickDB server, because
312
+ SidekickDB has no default server. Use the same `apiURI` as the project's existing
313
+ `init`, or `apiURI` in `sidekick.config.ts` or `instant.config.ts` (the first one
314
+ found wins).
315
+
316
+ ```tsx
317
+ import schema from '@/instant.schema';
318
+
319
+ // On client
320
+ import { init } from '@sidekickdb/react'; // or your relevant SidekickDB SDK
321
+ const clientDb = init({ apiURI, appId, schema });
322
+
323
+ // On backend
324
+ import { init } from '@sidekickdb/admin';
325
+ const adminDb = init({ apiURI, appId, adminToken, schema });
326
+ ```
327
+
328
+ ## Use `id()` to generate ids
329
+
330
+ Always use `id()` to generate ids for new entities
331
+
332
+ ```tsx
333
+ import { id } from '@sidekickdb/react'; // or your relevant SidekickDB SDK
334
+ import { clientDb } from '@/lib/clientDb';
335
+ clientDb.transact(clientDb.tx.todos[id()].create({ title: 'New Todo' }));
336
+ ```
337
+
338
+ ## Use SidekickDB utility types for data models
339
+
340
+ Always use SidekickDB utility types to type data models
341
+
342
+ ```tsx
343
+ import { AppSchema } from '@/instant.schema';
344
+
345
+ type Todo = InstaQLEntity<AppSchema, 'todos'>; // todo from clientDb.useQuery({ todos: {} })
346
+ type PostsWithProfile = InstaQLEntity<
347
+ AppSchema,
348
+ 'posts',
349
+ { author: { avatar: {} } }
350
+ >; // post from clientDb.useQuery({ posts: { author: { avatar: {} } } })
351
+ ```
352
+
353
+ ## Use `db.useAuth` or `db.subscribeAuth` for auth state
354
+
355
+ ```tsx
356
+ import { clientDb } from '@/lib/clientDb';
357
+
358
+ // For react/react-native apps use db.useAuth
359
+ function App() {
360
+ const { isLoading, user, error } = clientDb.useAuth();
361
+ if (isLoading) {
362
+ return null;
363
+ }
364
+ if (error) {
365
+ return <Error message={error.message} />;
366
+ }
367
+ if (user) {
368
+ return <Main />;
369
+ }
370
+ return <Login />;
371
+ }
372
+
373
+ // For vanilla JS apps use db.subscribeAuth
374
+ function App() {
375
+ renderLoading();
376
+ db.subscribeAuth((auth) => {
377
+ if (auth.error) {
378
+ renderAuthError(auth.error.message);
379
+ } else if (auth.user) {
380
+ renderLoggedInPage(auth.user);
381
+ } else {
382
+ renderSignInPage();
383
+ }
384
+ });
385
+ }
386
+ ```
387
+
388
+ ## Set custom properties at signup with `extraFields`
389
+
390
+ Pass `extraFields` to any sign-in method to write custom `$users` properties atomically on user creation.
391
+ Fields must be defined as optional attrs on `$users` in your schema.
392
+ Use the `created` boolean to scaffold data for new users.
393
+
394
+ ```tsx
395
+ // Set properties at signup
396
+ const { user, created } = await db.auth.signInWithMagicCode({
397
+ email,
398
+ code,
399
+ extraFields: { nickname, createdAt: Date.now() },
400
+ });
401
+
402
+ // Scaffold data for new users
403
+ if (created) {
404
+ db.transact([
405
+ db.tx.settings[id()]
406
+ .update({ theme: 'light', notifications: true })
407
+ .link({ user: user.id }),
408
+ ]);
409
+ }
410
+ ```
411
+
412
+ # Ad-hoc queries from the CLI
413
+
414
+ Run `npx @sidekickdb/cli query '{ posts: {} }' --admin` to query your app. A context flag is required: `--admin`, `--as-email <email>`, or `--as-guest`. Also supports `--app <id>`.
415
+
416
+ # SidekickDB Documentation
417
+
418
+ The bullets below are links to the SidekickDB documentation. They provide detailed information on how to use different features of SidekickDB. Each line follows the pattern of
419
+
420
+ - [TOPIC](URL): Description of the topic.
421
+
422
+ Fetch the URL for a topic to learn more about it.
423
+
424
+ - [Common mistakes](https://sidekickdb.co/docs/common-mistakes.md): Common mistakes when working with SidekickDB
425
+ - [Initializing SidekickDB](https://sidekickdb.co/docs/init.md): How to integrate SidekickDB with your app.
426
+ - [Modeling data](https://sidekickdb.co/docs/modeling-data.md): How to model data with SidekickDB's schema.
427
+ - [Writing data](https://sidekickdb.co/docs/instaml.md): How to write data with SidekickDB using InstaML.
428
+ - [Reading data](https://sidekickdb.co/docs/instaql.md): How to read data with SidekickDB using InstaQL.
429
+ - [SidekickDB on the Backend](https://sidekickdb.co/docs/backend.md): How to use SidekickDB on the server with the Admin SDK.
430
+ - [Patterns](https://sidekickdb.co/docs/patterns.md): Common patterns for working with SidekickDB.
431
+ - [Auth](https://sidekickdb.co/docs/auth/magic-codes.md): How to add magic code auth to your SidekickDB app.
432
+ - [Guest Auth](https://sidekickdb.co/docs/auth/guest-auth.md): How to add guest auth to your SidekickDB app.
433
+ - [Other Auth](https://sidekickdb.co/docs/auth.md): Additional auth methods supported by SidekickDB.
434
+ - [Managing users](https://sidekickdb.co/docs/users.md): How to manage users in your SidekickDB app.
435
+ - [Presence, Cursors, and Activity](https://sidekickdb.co/docs/presence-and-topics.md): How to add ephemeral features like presence and cursors to your SidekickDB app.
436
+ - [SidekickDB CLI](https://sidekickdb.co/docs/cli.md): How to use the SidekickDB CLI to manage schema.
437
+ - [Storage](https://sidekickdb.co/docs/storage.md): How to upload and serve files with SidekickDB.
438
+ - [Streams](https://sidekickdb.co/docs/streams.md): How to use streams with SidekickDB.
439
+ - [Stripe Payments](https://sidekickdb.co/docs/stripe-payments.md): How to integrate Stripe payments with SidekickDB.
440
+ - [React Native](https://sidekickdb.co/docs/start-rn.md): How to use SidekickDB in React Native apps.
441
+ - [Vanilla JS](https://sidekickdb.co/docs/start-vanilla.md): How to use SidekickDB in vanilla JS apps.
442
+ - [SolidJS](https://sidekickdb.co/docs/start-solidjs.md): How to use SidekickDB in SolidJS apps.
443
+ - [Svelte](https://sidekickdb.co/docs/start-svelte.md): How to use SidekickDB in Svelte apps.
444
+ - [Vue](https://sidekickdb.co/docs/start-vue.md): How to use SidekickDB in Vue apps.
445
+ - [TanStack](https://sidekickdb.co/docs/start-tanstack.md): How to use SidekickDB in TanStack apps.
446
+
447
+ # Final Note
448
+
449
+ Think before you answer. Make sure your code passes typechecks `tsc --noEmit` and works as expected.
450
+ Remember! AESTHETICS ARE VERY IMPORTANT. All apps should LOOK AMAZING and have GREAT FUNCTIONALITY!