stackkit-cli 0.4.2 → 0.4.3

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.
Files changed (133) hide show
  1. package/README.md +17 -10
  2. package/bin/stackkit.js +1 -1
  3. package/dist/commands/add.js +26 -24
  4. package/dist/commands/init.d.ts +1 -1
  5. package/dist/commands/init.js +34 -29
  6. package/dist/commands/list.js +12 -12
  7. package/dist/index.js +25 -23
  8. package/dist/types/index.d.ts +14 -14
  9. package/dist/utils/code-inject.d.ts +1 -1
  10. package/dist/utils/code-inject.js +6 -6
  11. package/dist/utils/detect.d.ts +1 -1
  12. package/dist/utils/detect.js +48 -44
  13. package/dist/utils/env-editor.js +20 -20
  14. package/dist/utils/files.js +4 -4
  15. package/dist/utils/json-editor.d.ts +3 -3
  16. package/dist/utils/json-editor.js +10 -14
  17. package/dist/utils/logger.d.ts +1 -1
  18. package/dist/utils/logger.js +8 -8
  19. package/dist/utils/package-manager.d.ts +2 -2
  20. package/dist/utils/package-manager.js +33 -26
  21. package/modules/auth/better-auth-express/adapters/mongoose-mongodb.ts +13 -0
  22. package/modules/auth/better-auth-express/adapters/prisma-mongodb.ts +15 -0
  23. package/modules/auth/better-auth-express/adapters/prisma-postgresql.ts +15 -0
  24. package/modules/auth/better-auth-express/files/lib/auth.ts +1 -1
  25. package/modules/auth/better-auth-express/files/routes/auth.ts +3 -3
  26. package/modules/auth/better-auth-express/files/schemas/prisma-mongodb-schema.prisma +72 -0
  27. package/modules/auth/better-auth-express/files/schemas/prisma-postgresql-schema.prisma +72 -0
  28. package/modules/auth/better-auth-express/module.json +26 -3
  29. package/modules/auth/better-auth-nextjs/adapters/mongoose-mongodb.ts +24 -0
  30. package/modules/auth/better-auth-nextjs/adapters/prisma-mongodb.ts +26 -0
  31. package/modules/auth/better-auth-nextjs/adapters/prisma-postgresql.ts +26 -0
  32. package/modules/auth/better-auth-nextjs/files/api/auth/[...all]/route.ts +2 -3
  33. package/modules/auth/better-auth-nextjs/files/lib/auth.ts +4 -4
  34. package/modules/auth/better-auth-nextjs/files/schemas/prisma-mongodb-schema.prisma +72 -0
  35. package/modules/auth/better-auth-nextjs/files/schemas/prisma-postgresql-schema.prisma +72 -0
  36. package/modules/auth/better-auth-nextjs/module.json +26 -5
  37. package/modules/auth/better-auth-react/files/lib/auth-client.ts +2 -2
  38. package/modules/auth/better-auth-react/module.json +7 -5
  39. package/modules/auth/clerk-express/files/lib/auth.ts +1 -1
  40. package/modules/auth/clerk-express/module.json +22 -8
  41. package/modules/auth/clerk-nextjs/files/lib/auth-provider.tsx +1 -1
  42. package/modules/auth/clerk-nextjs/files/middleware.ts +3 -3
  43. package/modules/auth/clerk-nextjs/module.json +50 -14
  44. package/modules/auth/clerk-react/files/lib/auth-provider.tsx +2 -2
  45. package/modules/auth/clerk-react/module.json +16 -7
  46. package/modules/database/mongoose-mongodb/files/lib/db.ts +3 -3
  47. package/modules/database/mongoose-mongodb/module.json +43 -6
  48. package/modules/database/prisma-mongodb/files/lib/db.ts +2 -2
  49. package/modules/database/prisma-mongodb/files/prisma/schema.prisma +1 -1
  50. package/modules/database/prisma-mongodb/module.json +28 -4
  51. package/modules/database/prisma-postgresql/files/lib/db.ts +2 -2
  52. package/modules/database/prisma-postgresql/files/prisma/schema.prisma +1 -1
  53. package/modules/database/prisma-postgresql/module.json +28 -4
  54. package/package.json +1 -1
  55. package/templates/express/.env.example +11 -0
  56. package/templates/express/eslint.config.cjs +42 -0
  57. package/templates/express/package.json +39 -0
  58. package/templates/express/src/app.ts +71 -0
  59. package/templates/express/src/config/env.ts +23 -0
  60. package/templates/express/src/middlewares/error.middleware.ts +18 -0
  61. package/templates/{bases/express-base → express}/src/server.ts +2 -2
  62. package/templates/express/template.json +44 -0
  63. package/templates/express/tsconfig.json +31 -0
  64. package/templates/{bases/nextjs-base → nextjs}/app/layout.tsx +1 -5
  65. package/templates/nextjs/app/page.tsx +57 -0
  66. package/templates/{bases/nextjs-base → nextjs}/package.json +2 -1
  67. package/templates/{bases/nextjs-base → nextjs}/template.json +13 -1
  68. package/templates/react-vite/.env.example +2 -0
  69. package/templates/react-vite/README.md +85 -0
  70. package/templates/react-vite/eslint.config.js +23 -0
  71. package/templates/{bases/react-vite-base → react-vite}/index.html +1 -0
  72. package/templates/{bases/react-vite-base → react-vite}/package.json +16 -2
  73. package/templates/react-vite/src/api/client.ts +47 -0
  74. package/templates/react-vite/src/api/services/user.service.ts +18 -0
  75. package/templates/react-vite/src/components/ErrorBoundary.tsx +51 -0
  76. package/templates/react-vite/src/components/Layout.tsx +13 -0
  77. package/templates/react-vite/src/components/Loading.tsx +8 -0
  78. package/templates/react-vite/src/components/SEO.tsx +49 -0
  79. package/templates/react-vite/src/config/constants.ts +5 -0
  80. package/templates/react-vite/src/hooks/index.ts +64 -0
  81. package/templates/react-vite/src/index.css +1 -0
  82. package/templates/react-vite/src/lib/queryClient.ts +12 -0
  83. package/templates/react-vite/src/main.tsx +22 -0
  84. package/templates/react-vite/src/pages/About.tsx +78 -0
  85. package/templates/react-vite/src/pages/Home.tsx +49 -0
  86. package/templates/react-vite/src/pages/NotFound.tsx +24 -0
  87. package/templates/react-vite/src/pages/UserProfile.tsx +40 -0
  88. package/templates/react-vite/src/router.tsx +33 -0
  89. package/templates/react-vite/src/types/api.d.ts +20 -0
  90. package/templates/react-vite/src/types/user.d.ts +6 -0
  91. package/templates/react-vite/src/utils/helpers.ts +51 -0
  92. package/templates/react-vite/src/utils/storage.ts +35 -0
  93. package/templates/react-vite/src/vite-env.d.ts +11 -0
  94. package/templates/react-vite/template.json +46 -0
  95. package/templates/react-vite/tsconfig.json +4 -0
  96. package/templates/react-vite/vite.config.ts +13 -0
  97. package/modules/database/drizzle-postgresql/files/drizzle.config.ts +0 -10
  98. package/modules/database/drizzle-postgresql/files/lib/db.ts +0 -7
  99. package/modules/database/drizzle-postgresql/files/lib/schema.ts +0 -8
  100. package/modules/database/drizzle-postgresql/module.json +0 -35
  101. package/templates/bases/express-base/.env.example +0 -2
  102. package/templates/bases/express-base/package.json +0 -23
  103. package/templates/bases/express-base/src/app.ts +0 -34
  104. package/templates/bases/express-base/src/config/env.ts +0 -14
  105. package/templates/bases/express-base/src/middlewares/error.middleware.ts +0 -12
  106. package/templates/bases/express-base/template.json +0 -7
  107. package/templates/bases/express-base/tsconfig.json +0 -14
  108. package/templates/bases/nextjs-base/app/page.tsx +0 -65
  109. package/templates/bases/react-vite-base/README.md +0 -73
  110. package/templates/bases/react-vite-base/eslint.config.js +0 -23
  111. package/templates/bases/react-vite-base/src/App.css +0 -42
  112. package/templates/bases/react-vite-base/src/App.tsx +0 -35
  113. package/templates/bases/react-vite-base/src/index.css +0 -68
  114. package/templates/bases/react-vite-base/src/main.tsx +0 -10
  115. package/templates/bases/react-vite-base/template.json +0 -19
  116. package/templates/bases/react-vite-base/tsconfig.json +0 -7
  117. package/templates/bases/react-vite-base/vite.config.ts +0 -7
  118. /package/templates/{bases/nextjs-base → nextjs}/README.md +0 -0
  119. /package/templates/{bases/nextjs-base → nextjs}/app/favicon.ico +0 -0
  120. /package/templates/{bases/nextjs-base → nextjs}/app/globals.css +0 -0
  121. /package/templates/{bases/nextjs-base → nextjs}/eslint.config.mjs +0 -0
  122. /package/templates/{bases/nextjs-base → nextjs}/next.config.ts +0 -0
  123. /package/templates/{bases/nextjs-base → nextjs}/postcss.config.mjs +0 -0
  124. /package/templates/{bases/nextjs-base → nextjs}/public/file.svg +0 -0
  125. /package/templates/{bases/nextjs-base → nextjs}/public/globe.svg +0 -0
  126. /package/templates/{bases/nextjs-base → nextjs}/public/next.svg +0 -0
  127. /package/templates/{bases/nextjs-base → nextjs}/public/vercel.svg +0 -0
  128. /package/templates/{bases/nextjs-base → nextjs}/public/window.svg +0 -0
  129. /package/templates/{bases/nextjs-base → nextjs}/tsconfig.json +0 -0
  130. /package/templates/{bases/react-vite-base → react-vite}/public/vite.svg +0 -0
  131. /package/templates/{bases/react-vite-base → react-vite}/src/assets/react.svg +0 -0
  132. /package/templates/{bases/react-vite-base → react-vite}/tsconfig.app.json +0 -0
  133. /package/templates/{bases/react-vite-base → react-vite}/tsconfig.node.json +0 -0
@@ -0,0 +1,85 @@
1
+ # React + Vite Template
2
+
3
+ A production-ready React starter template with TypeScript, Vite, and essential libraries pre-configured.
4
+
5
+ ## Features
6
+
7
+ - **React 19** with TypeScript
8
+ - **Vite 7** for fast development
9
+ - **React Router v7** for client-side routing
10
+ - **TanStack Query v5** for data fetching and caching
11
+ - **Axios** with interceptors
12
+ - **Tailwind CSS** for styling
13
+ - **React Hot Toast** for notifications
14
+ - **SEO Ready** with React Helmet Async
15
+ - **Error Boundaries** for graceful error handling
16
+ - **ESLint** for code quality
17
+ - **Custom Hooks** included
18
+
19
+ ## Quick Start
20
+
21
+ ```bash
22
+ # Install dependencies
23
+ pnpm install
24
+
25
+ # Start development server
26
+ pnpm dev
27
+
28
+ # Build for production
29
+ pnpm build
30
+
31
+ # Preview production build
32
+ pnpm preview
33
+ ```
34
+
35
+ ## Project Structure
36
+
37
+ ```
38
+ src/
39
+ ├── api/ # API client & interceptors
40
+ ├── components/ # Reusable UI components
41
+ ├── config/ # App configuration
42
+ ├── hooks/ # Custom React hooks
43
+ ├── lib/ # Library configurations
44
+ ├── pages/ # Route pages
45
+ ├── types/ # TypeScript types
46
+ ├── utils/ # Helper functions
47
+ ├── App.tsx # Main app component
48
+ ├── main.tsx # Entry point
49
+ └── index.css # Global styles
50
+ ```
51
+
52
+ ## Environment Variables
53
+
54
+ Create a `.env` file:
55
+
56
+ ```env
57
+ VITE_API_URL=http://localhost:3000/api
58
+ VITE_APP_NAME=My App
59
+ ```
60
+
61
+ ## Production Build
62
+
63
+ - Code splitting with vendor chunks
64
+ - Tree shaking to remove unused code
65
+ - Minified and compressed output
66
+ - TypeScript strict mode enabled
67
+ - ESLint configured for code quality
68
+
69
+ ## Deployment
70
+
71
+ ```bash
72
+ pnpm build
73
+ ```
74
+
75
+ Deploy the `dist` folder to Vercel, Netlify, or any static hosting service.
76
+
77
+ ## Tech Stack
78
+
79
+ - React 19 - UI library
80
+ - Vite 7 - Build tool
81
+ - TypeScript - Type safety
82
+ - React Router v7 - Routing
83
+ - TanStack Query v5 - Data fetching
84
+ - Axios - HTTP client
85
+ - Tailwind CSS - Styling
@@ -0,0 +1,23 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import reactHooks from "eslint-plugin-react-hooks";
4
+ import reactRefresh from "eslint-plugin-react-refresh";
5
+ import tseslint from "typescript-eslint";
6
+ import { defineConfig, globalIgnores } from "eslint/config";
7
+
8
+ export default defineConfig([
9
+ globalIgnores(["dist"]),
10
+ {
11
+ files: ["**/*.{ts,tsx}"],
12
+ extends: [
13
+ js.configs.recommended,
14
+ tseslint.configs.recommended,
15
+ reactHooks.configs.flat.recommended,
16
+ reactRefresh.configs.vite,
17
+ ],
18
+ languageOptions: {
19
+ ecmaVersion: 2020,
20
+ globals: globals.browser,
21
+ },
22
+ },
23
+ ]);
@@ -4,6 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <link href="/src/index.css" rel="stylesheet">
7
8
  <title>react-vite-base</title>
8
9
  </head>
9
10
  <body>
@@ -7,11 +7,22 @@
7
7
  "dev": "vite",
8
8
  "build": "tsc -b && vite build",
9
9
  "lint": "eslint .",
10
+ "lint:fix": "eslint . --fix",
10
11
  "preview": "vite preview"
11
12
  },
12
13
  "dependencies": {
14
+ "@tailwindcss/vite": "^4.1.18",
15
+ "@tanstack/react-query": "^5.62.0",
16
+ "@tanstack/react-query-devtools": "^5.62.0",
17
+ "axios": "^1.7.7",
18
+ "class-variance-authority": "^0.7.1",
19
+ "clsx": "^2.1.1",
13
20
  "react": "^19.2.0",
14
- "react-dom": "^19.2.0"
21
+ "react-dom": "^19.2.0",
22
+ "react-helmet-async": "^2.0.5",
23
+ "react-hot-toast": "^2.4.1",
24
+ "react-router": "^7.12.0",
25
+ "tailwind-merge": "^3.4.0"
15
26
  },
16
27
  "devDependencies": {
17
28
  "@eslint/js": "^9.39.1",
@@ -19,12 +30,15 @@
19
30
  "@types/react": "^19.2.5",
20
31
  "@types/react-dom": "^19.2.3",
21
32
  "@vitejs/plugin-react": "^5.1.1",
33
+ "autoprefixer": "^10.4.23",
22
34
  "eslint": "^9.39.1",
23
35
  "eslint-plugin-react-hooks": "^7.0.1",
24
36
  "eslint-plugin-react-refresh": "^0.4.24",
25
37
  "globals": "^16.5.0",
38
+ "postcss": "^8.5.6",
39
+ "tailwindcss": "^4.1.18",
26
40
  "typescript": "~5.9.3",
27
41
  "typescript-eslint": "^8.46.4",
28
42
  "vite": "^7.2.4"
29
43
  }
30
- }
44
+ }
@@ -0,0 +1,47 @@
1
+ import type { AxiosResponse } from "axios";
2
+ import axios, { AxiosError } from "axios";
3
+ import toast from "react-hot-toast";
4
+
5
+ const api = axios.create({
6
+ baseURL: import.meta.env.VITE_API_URL || "http://localhost:3000/api",
7
+ timeout: 10000,
8
+ headers: {
9
+ "Content-Type": "application/json",
10
+ },
11
+ });
12
+
13
+ api.interceptors.request.use(
14
+ (config) => {
15
+ const token = localStorage.getItem("auth_token");
16
+ if (token) {
17
+ config.headers.Authorization = `Bearer ${token}`;
18
+ }
19
+ return config;
20
+ },
21
+ (error: AxiosError) => {
22
+ return Promise.reject(error);
23
+ },
24
+ );
25
+
26
+ api.interceptors.response.use(
27
+ (response: AxiosResponse) => response,
28
+ (error: AxiosError) => {
29
+ if (error.response?.status === 401) {
30
+ localStorage.removeItem("auth_token");
31
+ toast.error("Session expired. Please login again.");
32
+ } else if (error.response?.status === 403) {
33
+ toast.error("You do not have permission to perform this action.");
34
+ } else if (error.response?.status === 404) {
35
+ toast.error("Resource not found.");
36
+ } else if (error.response?.status === 500) {
37
+ toast.error("Server error. Please try again later.");
38
+ } else if (error.code === "ECONNABORTED") {
39
+ toast.error("Request timeout. Please try again.");
40
+ } else if (!error.response) {
41
+ toast.error("Network error. Please check your connection.");
42
+ }
43
+ return Promise.reject(error);
44
+ },
45
+ );
46
+
47
+ export default api;
@@ -0,0 +1,18 @@
1
+ import api from "../client";
2
+
3
+ export const userService = {
4
+ getUser: async (id: string): Promise<User> => {
5
+ const response = await api.get<ApiResponse<User>>(`/users/${id}`);
6
+ return response.data.data;
7
+ },
8
+
9
+ getCurrentUser: async (): Promise<User> => {
10
+ const response = await api.get<ApiResponse<User>>("/users/me");
11
+ return response.data.data;
12
+ },
13
+
14
+ updateUser: async (id: string, data: Partial<User>): Promise<User> => {
15
+ const response = await api.patch<ApiResponse<User>>(`/users/${id}`, data);
16
+ return response.data.data;
17
+ },
18
+ };
@@ -0,0 +1,51 @@
1
+ import type { ErrorInfo, ReactNode } from "react";
2
+ import { Component } from "react";
3
+
4
+ interface Props {
5
+ children?: ReactNode;
6
+ fallback?: ReactNode;
7
+ }
8
+
9
+ interface State {
10
+ hasError: boolean;
11
+ error?: Error;
12
+ }
13
+
14
+ export class ErrorBoundary extends Component<Props, State> {
15
+ constructor(props: Props) {
16
+ super(props);
17
+ this.state = { hasError: false };
18
+ }
19
+
20
+ static getDerivedStateFromError(error: Error): State {
21
+ return { hasError: true, error };
22
+ }
23
+
24
+ componentDidCatch(error: Error, errorInfo: ErrorInfo) {
25
+ console.error("ErrorBoundary caught an error:", error, errorInfo);
26
+ }
27
+
28
+ render() {
29
+ if (this.state.hasError) {
30
+ if (this.props.fallback) {
31
+ return this.props.fallback;
32
+ }
33
+ return (
34
+ <div className="p-8 text-center">
35
+ <h2 className="text-2xl font-semibold">Something went wrong</h2>
36
+ <p className="mt-2 text-gray-600">
37
+ {this.state.error?.message || "An unexpected error occurred"}
38
+ </p>
39
+ <button
40
+ onClick={() => this.setState({ hasError: false, error: undefined })}
41
+ className="mt-4 flex h-12 w-full items-center justify-center rounded-full bg-white text-black px-5 transition-colors hover:bg-zinc-200 md:w-39.5"
42
+ >
43
+ Try again
44
+ </button>
45
+ </div>
46
+ );
47
+ }
48
+
49
+ return this.props.children;
50
+ }
51
+ }
@@ -0,0 +1,13 @@
1
+ import { Outlet } from "react-router";
2
+
3
+ export function Layout() {
4
+ return (
5
+ <div className="min-h-screen flex flex-col bg-black">
6
+ <main className="flex-1 max-w-7xl w-full mx-auto p-4">
7
+ <Outlet />
8
+ </main>
9
+ </div>
10
+ );
11
+ }
12
+
13
+ export default Layout;
@@ -0,0 +1,8 @@
1
+ export default function Loading({ message = "Loading..." }: { message?: string }) {
2
+ return (
3
+ <div className="loading-container">
4
+ <div className="loading-spinner"></div>
5
+ <p>{message}</p>
6
+ </div>
7
+ );
8
+ }
@@ -0,0 +1,49 @@
1
+ import { Helmet, HelmetProvider } from "react-helmet-async";
2
+
3
+ interface SEOProps {
4
+ title?: string;
5
+ description?: string;
6
+ keywords?: string;
7
+ image?: string;
8
+ url?: string;
9
+ }
10
+
11
+ const defaultSEO = {
12
+ title: "React App",
13
+ description: "A modern React application built with Vite",
14
+ keywords: "react, vite, typescript, spa",
15
+ image: "/og-image.png",
16
+ };
17
+
18
+ export function SEOProvider({ children }: { children: React.ReactNode }) {
19
+ return <HelmetProvider>{children}</HelmetProvider>;
20
+ }
21
+
22
+ export function SEO({ title, description, keywords, image, url }: SEOProps) {
23
+ const siteTitle = title ? `${title} | ${defaultSEO.title}` : defaultSEO.title;
24
+ const siteDescription = description || defaultSEO.description;
25
+ const siteKeywords = keywords || defaultSEO.keywords;
26
+ const siteImage = image || defaultSEO.image;
27
+ const siteUrl = url || window.location.href;
28
+
29
+ return (
30
+ <Helmet>
31
+ <title>{siteTitle}</title>
32
+ <meta name="description" content={siteDescription} />
33
+ <meta name="keywords" content={siteKeywords} />
34
+
35
+ <meta property="og:type" content="website" />
36
+ <meta property="og:title" content={siteTitle} />
37
+ <meta property="og:description" content={siteDescription} />
38
+ <meta property="og:image" content={siteImage} />
39
+ <meta property="og:url" content={siteUrl} />
40
+
41
+ <meta name="twitter:card" content="summary_large_image" />
42
+ <meta name="twitter:title" content={siteTitle} />
43
+ <meta name="twitter:description" content={siteDescription} />
44
+ <meta name="twitter:image" content={siteImage} />
45
+
46
+ <link rel="canonical" href={siteUrl} />
47
+ </Helmet>
48
+ );
49
+ }
@@ -0,0 +1,5 @@
1
+ export const APP_NAME = import.meta.env.VITE_APP_NAME || "React App";
2
+ export const APP_VERSION = import.meta.env.VITE_APP_VERSION || "1.0.0";
3
+ export const API_URL = import.meta.env.VITE_API_URL || "http://localhost:3000/api";
4
+ export const IS_DEV = import.meta.env.DEV;
5
+ export const IS_PROD = import.meta.env.PROD;
@@ -0,0 +1,64 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ export function useDebounce<T>(value: T, delay: number): T {
4
+ const [debouncedValue, setDebouncedValue] = useState<T>(value);
5
+
6
+ useEffect(() => {
7
+ const handler = setTimeout(() => {
8
+ setDebouncedValue(value);
9
+ }, delay);
10
+
11
+ return () => {
12
+ clearTimeout(handler);
13
+ };
14
+ }, [value, delay]);
15
+
16
+ return debouncedValue;
17
+ }
18
+
19
+ export function useLocalStorage<T>(
20
+ key: string,
21
+ initialValue: T,
22
+ ): [T, (value: T | ((val: T) => T)) => void] {
23
+ const [storedValue, setStoredValue] = useState<T>(() => {
24
+ try {
25
+ const item = window.localStorage.getItem(key);
26
+ return item ? JSON.parse(item) : initialValue;
27
+ } catch (error) {
28
+ console.error(error);
29
+ return initialValue;
30
+ }
31
+ });
32
+
33
+ const setValue = (value: T | ((val: T) => T)) => {
34
+ try {
35
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
36
+ setStoredValue(valueToStore);
37
+ window.localStorage.setItem(key, JSON.stringify(valueToStore));
38
+ } catch (error) {
39
+ console.error(error);
40
+ }
41
+ };
42
+
43
+ return [storedValue, setValue];
44
+ }
45
+
46
+ export function useMediaQuery(query: string): boolean {
47
+ const [matches, setMatches] = useState(() => {
48
+ if (typeof window !== "undefined") {
49
+ return window.matchMedia(query).matches;
50
+ }
51
+ return false;
52
+ });
53
+
54
+ useEffect(() => {
55
+ const media = window.matchMedia(query);
56
+
57
+ const listener = () => setMatches(media.matches);
58
+ media.addEventListener("change", listener);
59
+
60
+ return () => media.removeEventListener("change", listener);
61
+ }, [query]);
62
+
63
+ return matches;
64
+ }
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,12 @@
1
+ import { QueryClient } from "@tanstack/react-query";
2
+
3
+ export const queryClient = new QueryClient({
4
+ defaultOptions: {
5
+ queries: {
6
+ staleTime: 1000 * 60 * 5, // 5 minutes
7
+ gcTime: 1000 * 60 * 10, // 10 minutes (formerly cacheTime)
8
+ retry: 1,
9
+ refetchOnWindowFocus: false,
10
+ },
11
+ },
12
+ });
@@ -0,0 +1,22 @@
1
+ import { QueryClientProvider } from "@tanstack/react-query";
2
+ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
3
+ import { StrictMode } from "react";
4
+ import { createRoot } from "react-dom/client";
5
+ import { Toaster } from "react-hot-toast";
6
+ import { RouterProvider } from "react-router";
7
+ import { SEOProvider } from "./components/SEO";
8
+ import "./index.css";
9
+ import { queryClient } from "./lib/queryClient";
10
+ import { router } from "./router";
11
+
12
+ createRoot(document.getElementById("root")!).render(
13
+ <StrictMode>
14
+ <SEOProvider>
15
+ <QueryClientProvider client={queryClient}>
16
+ <RouterProvider router={router} />
17
+ <Toaster position="top-right" />
18
+ <ReactQueryDevtools initialIsOpen={false} />
19
+ </QueryClientProvider>
20
+ </SEOProvider>
21
+ </StrictMode>,
22
+ );
@@ -0,0 +1,78 @@
1
+ import { SEO } from "../components/SEO";
2
+
3
+ export default function About() {
4
+ return (
5
+ <>
6
+ <SEO title="About" description="About Stackkit - A production-ready React starter template" />
7
+
8
+ <div className="flex min-h-screen items-center justify-center bg-black">
9
+ <main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-black sm:items-start">
10
+ <div className="flex items-center gap-4 mb-8">
11
+ <div className="text-2xl font-bold text-white">Stackkit</div>
12
+ <span className="text-xl text-zinc-400">+</span>
13
+ <img src="https://react.dev/favicon.ico" alt="React logo" width={32} height={32} />
14
+ </div>
15
+
16
+ <div className="flex flex-col gap-12 sm:text-left">
17
+ <div>
18
+ <h1 className="text-3xl font-semibold leading-10 tracking-tight text-zinc-50 mb-6">
19
+ About this template
20
+ </h1>
21
+ <p className="text-lg leading-8 text-zinc-400 mb-8">
22
+ Stackkit is a production-ready React starter template that includes all the
23
+ essential tools you need to build modern web applications.
24
+ </p>
25
+ </div>
26
+
27
+ <div>
28
+ <h2 className="text-xl font-semibold text-zinc-50 mb-4">What's included</h2>
29
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4 text-zinc-400">
30
+ <div className="p-4 border border-zinc-800 rounded-lg">
31
+ <div className="font-medium text-zinc-50 mb-1">React 19</div>
32
+ <div className="text-sm">Latest React with TypeScript</div>
33
+ </div>
34
+ <div className="p-4 border border-zinc-800 rounded-lg">
35
+ <div className="font-medium text-zinc-50 mb-1">Vite 7</div>
36
+ <div className="text-sm">Fast build tool and dev server</div>
37
+ </div>
38
+ <div className="p-4 border border-zinc-800 rounded-lg">
39
+ <div className="font-medium text-zinc-50 mb-1">React Router</div>
40
+ <div className="text-sm">Client-side routing</div>
41
+ </div>
42
+ <div className="p-4 border border-zinc-800 rounded-lg">
43
+ <div className="font-medium text-zinc-50 mb-1">TanStack Query</div>
44
+ <div className="text-sm">Data fetching and caching</div>
45
+ </div>
46
+ <div className="p-4 border border-zinc-800 rounded-lg">
47
+ <div className="font-medium text-zinc-50 mb-1">Axios</div>
48
+ <div className="text-sm">HTTP client with interceptors</div>
49
+ </div>
50
+ <div className="p-4 border border-zinc-800 rounded-lg">
51
+ <div className="font-medium text-zinc-50 mb-1">Tailwind CSS</div>
52
+ <div className="text-sm">Utility-first CSS framework</div>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </div>
57
+
58
+ <div className="flex flex-col gap-4 text-base font-medium sm:flex-row mt-8">
59
+ <a
60
+ className="flex h-12 w-full items-center justify-center rounded-full bg-white text-black px-5 transition-colors hover:bg-zinc-200 md:w-39.5"
61
+ href="/"
62
+ >
63
+ Back to Home
64
+ </a>
65
+ <a
66
+ className="flex h-12 w-full items-center justify-center rounded-full px-5 transition-colors hover:border-transparent bg-zinc-900 md:w-39.5 dark:text-white text-black"
67
+ href="https://stackkit.tariqul.dev"
68
+ target="_blank"
69
+ rel="noopener noreferrer"
70
+ >
71
+ Website
72
+ </a>
73
+ </div>
74
+ </main>
75
+ </div>
76
+ </>
77
+ );
78
+ }
@@ -0,0 +1,49 @@
1
+ import { SEO } from "../components/SEO";
2
+
3
+ export default function Home() {
4
+ return (
5
+ <>
6
+ <SEO title="Home" />
7
+ <div className="flex min-h-screen items-center justify-center bg-black">
8
+ <main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-black sm:items-start">
9
+ <div className="flex items-center gap-4 mb-8">
10
+ <div className="text-2xl font-bold text-white">Stackkit</div>
11
+ <span className="text-xl text-zinc-400">+</span>
12
+ <img src="https://react.dev/favicon.ico" alt="React logo" width={32} height={32} />
13
+ </div>
14
+
15
+ <div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
16
+ <h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-zinc-50">
17
+ To get started, edit the Home.tsx file.
18
+ </h1>
19
+ <p className="max-w-md text-lg leading-8 text-zinc-400">
20
+ This template includes React Router, TanStack Query, Axios, and Tailwind CSS. Check
21
+ out the{" "}
22
+ <a href="/about" className="font-medium text-zinc-50 hover:underline">
23
+ About
24
+ </a>{" "}
25
+ page to learn more about the included features.
26
+ </p>
27
+ </div>
28
+
29
+ <div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
30
+ <a
31
+ className="flex h-12 w-full items-center justify-center rounded-full bg-white text-black px-5 transition-colors hover:bg-zinc-200 md:w-39.5"
32
+ href="https://react.dev"
33
+ target="_blank"
34
+ rel="noopener noreferrer"
35
+ >
36
+ Get Started
37
+ </a>
38
+ <a
39
+ className="flex h-12 w-full items-center justify-center rounded-full px-5 transition-colors hover:border-transparent bg-zinc-900 md:w-39.5 dark:text-white text-black"
40
+ href="/about"
41
+ >
42
+ Documentation
43
+ </a>
44
+ </div>
45
+ </main>
46
+ </div>
47
+ </>
48
+ );
49
+ }
@@ -0,0 +1,24 @@
1
+ import { Link } from "react-router";
2
+ import { SEO } from "../components/SEO";
3
+
4
+ export default function NotFound() {
5
+ return (
6
+ <>
7
+ <SEO title="404 - Page Not Found" description="The page you're looking for doesn't exist" />
8
+
9
+ <div className="flex min-h-screen items-center justify-center bg-black">
10
+ <div className="text-center px-6">
11
+ <h1 className="text-8xl font-bold text-white mb-4">404</h1>
12
+ <h2 className="text-3xl font-semibold text-zinc-50 mb-4">Page Not Found</h2>
13
+ <p className="text-lg text-zinc-400 mb-8">The page you're looking for doesn't exist.</p>
14
+ <Link
15
+ to="/"
16
+ className="inline-flex h-12 items-center justify-center rounded-full bg-white text-black px-8 font-medium transition-colors hover:bg-zinc-200"
17
+ >
18
+ Go Home
19
+ </Link>
20
+ </div>
21
+ </div>
22
+ </>
23
+ );
24
+ }
@@ -0,0 +1,40 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { useLoaderData, useParams } from "react-router";
3
+ import { userService } from "../api/services/user.service";
4
+
5
+ type User = { id?: string; name?: string; email?: string; avatar?: string; [key: string]: any };
6
+
7
+ export default function UserProfile() {
8
+ const loaderUser = useLoaderData() as User | undefined;
9
+ const { userId } = useParams();
10
+
11
+ const { data: user = loaderUser ?? {} } = useQuery({
12
+ queryKey: ["user", userId],
13
+ queryFn: async () => {
14
+ if (!userId) throw new Error("Missing user id");
15
+ return await userService.getUser(userId);
16
+ },
17
+ initialData: loaderUser,
18
+ staleTime: 1000 * 60,
19
+ });
20
+
21
+ return (
22
+ <div className="min-h-screen bg-black text-white flex items-center justify-center">
23
+ <div className="max-w-xl p-8 bg-zinc-900 rounded-md shadow">
24
+ <div className="flex items-center gap-4">
25
+ {user.avatar ? (
26
+ <img src={user.avatar} alt={user.name} className="w-16 h-16 rounded-full" />
27
+ ) : (
28
+ <div className="w-16 h-16 rounded-full bg-zinc-700 flex items-center justify-center text-xl">
29
+ {user.name?.[0] ?? "U"}
30
+ </div>
31
+ )}
32
+ <div>
33
+ <h2 className="text-2xl font-semibold">{user.name}</h2>
34
+ <p className="text-sm text-zinc-400">{user.email}</p>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ );
40
+ }