@shophost/react 2.0.35 → 2.0.37

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.
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # @shophost/react
2
+
3
+ `@shophost/react` is the UI package for ShopHost. It provides:
4
+
5
+ - the admin app shell and route helpers
6
+ - Next.js App Router server entrypoints
7
+ - storefront providers, pages, and reusable components
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pnpm add @shophost/react @shophost/rest-api @prisma/client @prisma/client-runtime-utils
13
+ ```
14
+
15
+ Peer dependencies:
16
+
17
+ - `next >= 14`
18
+ - `react >= 18`
19
+ - `react-dom >= 18`
20
+
21
+ ## Entry Points
22
+
23
+ - `@shophost/react`
24
+ Use for admin config, route helpers, and auth helpers.
25
+ - `@shophost/react/next/server`
26
+ Use for App Router server-safe exports like `RootPage`.
27
+ - `@shophost/react/storefront`
28
+ Use for storefront providers, checkout/account pages, cart UI, and hooks.
29
+
30
+ ## Admin Usage
31
+
32
+ Create an admin config:
33
+
34
+ ```ts
35
+ import { defineConfig } from "@shophost/react";
36
+
37
+ export const adminConfig = defineConfig({
38
+ apiBaseUrl: process.env.NEXT_PUBLIC_API_BASE_URL!,
39
+ basePath: "/admin",
40
+ branding: {
41
+ name: "ShopHost",
42
+ },
43
+ });
44
+ ```
45
+
46
+ Mount the admin routes in Next.js App Router:
47
+
48
+ ```tsx
49
+ import { generatePageMetadata, RootPage } from "@shophost/react/next/server";
50
+ import type { Metadata } from "next";
51
+
52
+ import { adminConfig } from "../config";
53
+
54
+ export function generateMetadata(): Metadata {
55
+ return generatePageMetadata(adminConfig);
56
+ }
57
+
58
+ export default function Page(props: { params: Promise<{ segments?: string[] }> }) {
59
+ return <RootPage {...props} config={adminConfig} />;
60
+ }
61
+ ```
62
+
63
+ Create the matching not-found page:
64
+
65
+ ```tsx
66
+ export { NotFoundPage as default } from "@shophost/react/next/server";
67
+ ```
68
+
69
+ Useful root exports:
70
+
71
+ - `defineConfig`
72
+ - `createRoutes`
73
+ - `createAdminAuthClient`
74
+ - `getAdminAuthClient`
75
+
76
+ ## Storefront Usage
77
+
78
+ Wrap your storefront with `ShophostProvider`:
79
+
80
+ ```tsx
81
+ "use client";
82
+
83
+ import type { Locale } from "@shophost/client";
84
+ import { ModifiersDialog, ShophostProvider } from "@shophost/react/storefront";
85
+ import React from "react";
86
+
87
+ export function AppProvider({ children, locale }: { children: React.ReactNode; locale: Locale }) {
88
+ return (
89
+ <ShophostProvider baseUrl={process.env.NEXT_PUBLIC_APP_DOMAIN!} locale={locale} organizationId={process.env.NEXT_PUBLIC_ORGANIZATION_ID!} modifiersModal={<ModifiersDialog />}>
90
+ {children}
91
+ </ShophostProvider>
92
+ );
93
+ }
94
+ ```
95
+
96
+ Mount the built-in checkout and account flows:
97
+
98
+ ```tsx
99
+ "use client";
100
+
101
+ import { AccountPages, CheckoutPages } from "@shophost/react/storefront";
102
+
103
+ export function CheckoutRoute() {
104
+ return <CheckoutPages />;
105
+ }
106
+
107
+ export function AccountRoute() {
108
+ return <AccountPages />;
109
+ }
110
+ ```
111
+
112
+ Useful storefront exports:
113
+
114
+ - `ShophostProvider`
115
+ - `CheckoutPages`
116
+ - `AccountPages`
117
+ - `CartDrawer`
118
+ - `CartItems`
119
+ - `ModifiersDialog`
120
+ - `useCart`
121
+ - `useAPI`
122
+ - `useOrganization`
123
+
124
+ ## Reference App
125
+
126
+ For a complete integration, see `apps/example` and the workspace README in the
127
+ repository root.
128
+
129
+ ## License
130
+
131
+ MIT
@@ -1,3 +1 @@
1
- import { KpiEntry, KpiEntryExtended, PeriodValue } from '../components/overview/dashboard-types';
2
- export type { PeriodValue, KpiEntry, KpiEntryExtended };
3
1
  export declare function DashboardView(): import("react/jsx-runtime").JSX.Element;