Loading...
Loading...
Comprehensive guide for building full-stack applications with Convex and TanStack Start. This skill should be used when working on projects that use Convex as the backend database with TanStack Start (React meta-framework). Covers schema design, queries, mutations, actions, authentication with Better Auth, routing, data fetching patterns, SSR, file storage, scheduling, AI agents, and frontend patterns. Use this when implementing features, debugging issues, or needing guidance on Convex + TanStack Start best practices.
npx skill4agent add sstobo/convex-skills convex-tanstack// Data fetching (always use cached version)
import { useQuery } from 'convex-helpers/react/cache'
import { useMutation, useAction } from 'convex/react'
// SSR with React Query
import { useSuspenseQuery } from '@tanstack/react-query'
import { convexQuery } from '@convex-dev/react-query'
// API and types
import { api } from '~/convex/_generated/api'
import type { Id, Doc } from '~/convex/_generated/dataModel'
// Backend functions
import { query, mutation, action } from "./_generated/server"
import { v } from "convex/values""skip"const user = useQuery(api.users.get, userId ? { userId } : "skip")
const org = useQuery(api.orgs.get, user?.orgId ? { orgId: user.orgId } : "skip")if (data === undefined) return <Skeleton /> // Loading
if (data === null) return <NotFound /> // Not found
return <Content data={data} /> // Successexport const getUser = query({
args: { userId: v.id("users") },
returns: v.union(
v.object({ _id: v.id("users"), name: v.string() }),
v.null()
),
handler: async (ctx, args) => {
return await ctx.db.get(args.userId)
},
})// Schema - name includes all fields
.index("by_organizationId_status", ["organizationId", "status"])
// Query - fields in same order as index
.withIndex("by_organizationId_status", (q) =>
q.eq("organizationId", orgId).eq("status", "published")
)import { authComponent } from "./auth"
const user = await authComponent.getAuthUser(ctx)
if (!user) throw new Error("Not authenticated").filter()| Wrong | Correct |
|---|---|
| |
| |
| |
Action with | Use |
| `count |
| File | Use When |
|---|---|
| Project setup, config files, environment variables |
| Router setup, root route, file-based routing, layouts |
| Better Auth setup, sign up/in/out, protected routes, SSR auth |
| useQuery, useSuspenseQuery, mutations, loaders, prefetching |
| Schema, queries, mutations, actions, internal functions, HTTP endpoints |
| TypeScript patterns, validators, type mapping |
| File upload, download, metadata, deletion |
| scheduler.runAfter, cron jobs |
| AI agents, tools, RAG setup |
| Component patterns, loading states, Tailwind/shadcn |
| Role hierarchy, feature access patterns |
| Dev commands, Convex CLI, Vercel deployment |
| Import cheatsheet, common patterns summary |
01-setup.md03-auth.md05-backend.md04-data-fetching.md10-frontend.md13-quick-reference.md