Vite + Hono + TanStack port of the Shopify storefront

Ports nextjs-templates/shopify-storefront to Vite, TanStack Router/Query,
Tailwind v4 and Hono, without the AI store assistant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Rami Bitar
2026-10-03 11:27:27 -04:00
co-authored by Claude Opus 5.5
commit c447c51e82
82 changed files with 11712 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import { queryOptions } from '@tanstack/react-query';
import type { Customer } from '@/services/shopify/customer';
// The customer token lives in an httpOnly cookie, so account state always comes
// from the Hono API (server/account.ts) rather than from Shopify directly.
export interface SessionCustomer {
displayName: string;
email: string;
firstName?: string | null;
}
async function getJson<T>(url: string): Promise<T> {
const response = await fetch(url, { credentials: 'same-origin' });
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
return response.json();
}
/** Every account query shares this prefix, so sign-in/out can reset them all. */
export const ACCOUNT_QUERY_KEY = ['account'] as const;
export const sessionQueryOptions = () =>
queryOptions({
queryKey: [...ACCOUNT_QUERY_KEY, 'me'],
queryFn: () =>
getJson<{ customer: SessionCustomer | null }>('/api/account/me')
.then((data) => data.customer)
// A failed probe reads as signed out.
.catch(() => null),
});
export const customerQueryOptions = () =>
queryOptions({
queryKey: [...ACCOUNT_QUERY_KEY, 'customer'],
queryFn: () =>
getJson<{ customer: Customer | null }>('/api/account/customer').then(
(data) => data.customer
),
// Orders should reflect a purchase made a moment ago.
staleTime: 0,
});