Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ import { FormEvent, useState } from "react";
import { api } from "../convex/_generated/api.js";

// Build a global convexClient wherever you would normally create a TanStack Query client.
const convexClient = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL);
const isServer = typeof window === "undefined";

console.log({ isServer });

const url = isServer
? import.meta.env.VITE_CONVEX_URL
: "http://foo-bar-baz.convex.cloud";

const convexClient = new ConvexReactClient(url);
const convexQueryClient = new ConvexQueryClient(convexClient);
const queryClient = new QueryClient({
defaultOptions: {
Expand Down Expand Up @@ -70,7 +78,7 @@ function Weather() {
function MessageCount() {
const [shown, setShown] = useState(true);
// This is a conditional query
const { data, isPending, error } = useQuery(
const { data, isPending, error } = useSuspenseQuery(
convexQuery(api.messages.count, shown ? {} : "skip"),
);
return (
Expand Down