izen-react-starter 2.2.8 → 2.3.0

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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A modern React component library built with Vite, TypeScript, and best practices.
4
4
 
5
+ ## Changelog
6
+
7
+ - 2026-01-02: `BrowserRouter` removed from inside `AppProvider`. Consumers must wrap `AppProvider` (and any `react-router-dom` usage) in their own router at the app root.
8
+
5
9
  ## Features
6
10
 
7
11
  - 🎨 **UI Components**: Pre-built, customizable components (Button, Card, etc.)
@@ -54,24 +58,39 @@ The library includes Tailwind CSS with pre-configured theme variables for:
54
58
 
55
59
  ### App Provider (All-in-one)
56
60
 
57
- Wrap your application with `AppProvider` to get all providers in one go:
61
+ Wrap your application with `BrowserRouter` at the root. `AppProvider` no longer creates a router internally so you control the router setup in your app entry point:
58
62
 
59
63
  ```tsx
64
+ import { BrowserRouter } from 'react-router-dom';
60
65
  import { AppProvider } from 'izen-react-starter';
61
66
  import { AppRouter } from './routes';
62
67
 
63
68
  function App() {
64
69
  return (
65
- <AppProvider
66
- defaultTheme="light"
67
- showReactQueryDevtools={true}
68
- >
69
- <AppRouter />
70
- </AppProvider>
70
+ <BrowserRouter>
71
+ <AppProvider
72
+ defaultTheme="light"
73
+ showReactQueryDevtools={true}
74
+ // Option A: merge extra react-query defaults
75
+ queryClientOptions={{
76
+ defaultOptions: {
77
+ queries: {
78
+ retry: 1,
79
+ },
80
+ },
81
+ }}
82
+ // Option B: supply a custom QueryClient instance
83
+ // queryClient={myCustomClient}
84
+ >
85
+ <AppRouter />
86
+ </AppProvider>
87
+ </BrowserRouter>
71
88
  );
72
89
  }
73
90
  ```
74
91
 
92
+ > Recent change: `BrowserRouter` was removed from inside `AppProvider`. Always wrap `AppProvider` (or any components using `react-router-dom` hooks/components) in your own router at the application root.
93
+
75
94
  ### Authentication
76
95
 
77
96
  ```tsx
@@ -106,6 +125,23 @@ function ProfilePage() {
106
125
  }
107
126
  ```
108
127
 
128
+ #### Typing `useAuth`
129
+
130
+ `useAuth` is generic. Bring your own user shape for full IntelliSense:
131
+
132
+ ```tsx
133
+ import { useAuth } from 'izen-react-starter';
134
+
135
+ type MyUser = {
136
+ id: string;
137
+ name: string;
138
+ role: 'admin' | 'user';
139
+ };
140
+
141
+ const { user, setAuthData } = useAuth<MyUser>();
142
+ setAuthData({ id: '1', name: 'Ada', role: 'admin' }, { access_token: 'jwt' });
143
+ ```
144
+
109
145
  ### Protected Routes
110
146
 
111
147
  ```tsx
@@ -127,6 +163,17 @@ function AppRouter() {
127
163
  }
128
164
  ```
129
165
 
166
+ > Make sure these routes are rendered inside your app-level router (e.g., `BrowserRouter`) that wraps `AppProvider`, so `RequiredAuth` and router hooks have a valid router context.
167
+
168
+ Optional guard: pass `canAccess` for custom checks (e.g., roles/claims) in addition to the default `auth?.user` presence.
169
+
170
+ ```tsx
171
+ <Route element={<RequiredAuth canAccess={(auth) => Boolean(auth?.user && auth?.user.role === 'admin')} />}
172
+ path="/admin"
173
+ element={<AdminPage />}
174
+ />
175
+ ```
176
+
130
177
  ### App Router Hook (Simplified Routing)
131
178
 
132
179
  The `useAppRouter` hook simplifies route configuration by automatically handling:
@@ -1,7 +1,7 @@
1
1
  var ws = Object.defineProperty;
2
2
  var xs = (e, t, n) => t in e ? ws(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var Re = (e, t, n) => xs(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { b as $e, d as B, o as xt, e as H, c as L, a as v, P as zo, m as ye, S as K, t as P, i as k, f as U, h as F, j as $s, k as sr, u as Ce, l as V, s as Vn, n as jn, p as ft, q as T, r as Cs, v as cn, w as qe, x as Ss, y as _t, z as Kt, A as ks, B as Es, C as Cn, F as Ds, D as Hr, E as Nt, $ as Ko, G as Ms, H as As, I as W, J as Gr, K as Ts, L as Fs, M as ar, N as Is, O as Os, Q as Kn, R as Ls, T as Ps, U as ie, V as qs, W as _s } from "./index-BqTfpBWD.js";
4
+ import { b as $e, d as B, o as xt, e as H, c as L, a as v, P as zo, m as ye, S as K, t as P, i as k, f as U, h as F, j as $s, k as sr, u as Ce, l as V, s as Vn, n as jn, p as ft, q as T, r as Cs, v as cn, w as qe, x as Ss, y as _t, z as Kt, A as ks, B as Es, C as Cn, F as Ds, D as Hr, E as Nt, $ as Ko, G as Ms, H as As, I as W, J as Gr, K as Ts, L as Fs, M as ar, N as Is, O as Os, Q as Kn, R as Ls, T as Ps, U as ie, V as qs, W as _s } from "./index-DGFW2ITH.js";
5
5
  var Rs = (e) => e != null, zs = (e) => e.filter(Rs);
6
6
  function Ks(e) {
7
7
  return (...t) => {
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./MIMHJGAX-QHfr44HB.js";
2
- import { g as d, c as f, a as e } from "./index-BqTfpBWD.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./MIMHJGAX-CkycM4_6.js";
2
+ import { g as d, c as f, a as e } from "./index-DGFW2ITH.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,5 +1,5 @@
1
- import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./MIMHJGAX-QHfr44HB.js";
2
- import { g as h, c as v, a as e } from "./index-BqTfpBWD.js";
1
+ import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./MIMHJGAX-CkycM4_6.js";
2
+ import { g as h, c as v, a as e } from "./index-DGFW2ITH.js";
3
3
  var C = (r) => {
4
4
  const [t, o] = s({
5
5
  prefix: "TanstackQueryDevtools"