alpha

Gives Cursor a Next.js App Router pattern with TanStack Query v5: server prefetch with HydrationBoundary, Server Actions as mutations, optimistic updates and infinite scroll.
description: "Next.js App Router combined with TanStack Query v5 — HydrationBoundary pattern, Server Actions as mutations, optimistic updates, and infinite scroll"
globs: ["app//*.tsx", "app//.ts", "src/app/**/.tsx", "src/queries/**/*"]
alwaysApply: false
You are an expert in Next.js App Router, TanStack Query v5, TypeScript, and combining server components with client-side data fetching.
// providers/query-provider.tsx
'use client'
export function QueryProvider({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(() => new QueryClient({
defaultOptions: { queries: { staleTime: 60 * 1000 } },
}))
return (
<QueryClientProvider client={queryClient}>
{children}
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
)
}
// app/posts/page.tsx (Server Component)
export default async function PostsPage() {
const queryClient = new QueryClient()
await queryClient.prefetchQuery(postsQueryOptions())
return (
<HydrationBoundary state={dehydrate(queryClient)}>
<PostsList />
</HydrationBoundary>
)
}
// app/posts/_components/posts-list.tsx (Client Component)
'use client'
export function PostsList() {
const { data: posts } = useQuery(postsQueryOptions()) // reads from pre-populated cache
return <ul>{posts?.map(p => <li key={p.id}>{p.title}</li>)}</ul>
}
export const postsQueryOptions = (filters?: PostFilters) =>
queryOptions({
queryKey: ['posts', 'list', filters],
queryFn: () => fetch('/api/posts').then(r => r.json()),
})
// app/posts/actions.ts
'use server'
export async function createPost(data: { title: string; body: string }) {
const post = await db.post.create({ data })
revalidatePath('/posts')
return post
}
// usage in Client Component
const mutation = useMutation({
mutationFn: createPost,
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['posts', 'list'] }),
})
const mutation = useMutation({
mutationFn: updatePost,
onMutate: async (updated) => {
await queryClient.cancelQueries({ queryKey: ['posts', 'detail', updated.id] })
const previous = queryClient.getQueryData(['posts', 'detail', updated.id])
queryClient.setQueryData(['posts', 'detail', updated.id], (old: Post) => ({ ...old, ...updated }))
return { previous }
},
onError: (_, updated, ctx) => {
queryClient.setQueryData(['posts', 'detail', updated.id], ctx?.previous)
},
onSettled: (_, __, updated) => {
queryClient.invalidateQueries({ queryKey: ['posts', 'detail', updated.id] })
},
})
QueryClient per request in Server Components — never reuse across requestsQueryClient per browser session via useState in the providerHydrationBoundary'use client'fetch directly in Client Components — always go through queryFnPublic domain (CC0 1.0) · by awesome-cursorrules contributors · source · posted by @OpenSourceBuffGuy on promptparty.com


Green furry puppet grouch in trash can on Halloween street
Turns an uploaded face photo into a grumpy green shaggy puppet creature sitting in a dented trash can on a moonlit Halloween street lined with jack-o'-lanterns.
image-prompt, reference-image, face-reference, photo-editing, halloween, holiday, 3d-render, portrait, night-scene, whimsical, cinematic, dramatic-lighting, bokeh, vertical-format, gpt-image, humorous, creatures, long-form

Creates a vertical Fujifilm-style analog portrait of a young Japanese couple sitting close by a window in soft daylight, with muted pastel tones.
image-prompt, gpt-image, couple, portrait, film-photography, film-grain, photorealistic, japan, natural-light, soft-lighting, pastel, muted-colors, vertical-format, medium-shot, candid, romance, relationships, cozy, dreamy, vintage, photography, for-photographers

Builds three to five year startup financial models with cohort revenue, cost structure, cash flow, runway and scenarios for seed or Series A investors.
agent-skill, financial-model, startup, fundraising, corporate-finance, financial-analysis, forecasting, saas, kpis, business-plan, calculator, spreadsheet, for-founders, for-investors, advanced, long-form, structured-output, pitch-deck, pricing, estimation, report, venture-capital, business-strategy, excel, runway
Loading reviews…
Loading comments…