rkk-next 1.0.0 โ 1.1.1
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 +397 -128
- package/dist/backend/cache.d.ts +49 -0
- package/dist/backend/cache.js +166 -0
- package/dist/backend/middleware.d.ts +43 -0
- package/dist/backend/middleware.js +185 -0
- package/dist/backend/optimization.d.ts +63 -0
- package/dist/backend/optimization.js +186 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/package.json +23 -6
package/README.md
CHANGED
|
@@ -1,218 +1,487 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="./assets/logo.svg" alt="rkk-next logo" width="120" height="120" />
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](./LICENSE)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
5
|
+
# rkk-next
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
**Production-ready SEO, Performance & Routing SDK for Next.js**
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
[](https://www.npmjs.com/package/rkk-next)
|
|
10
|
+
[](https://www.npmjs.com/package/rkk-next)
|
|
11
|
+
[](./LICENSE)
|
|
12
|
+
[](https://www.typescriptlang.org/)
|
|
13
|
+
[](https://github.com/ROHIT8759/rkk-next)
|
|
14
|
+
[](https://github.com/ROHIT8759/rkk-next)
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
**Enterprise-grade toolkit for building SEO-optimized, lightning-fast Next.js applications**
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
- โ
Centralized meta management (OpenGraph, Twitter Cards)
|
|
18
|
-
- โ
JSON-LD structured data (Schema.org)
|
|
19
|
-
- โ
Canonical URL handling
|
|
20
|
-
- โ
SEO-safe defaults & best practices
|
|
18
|
+
[Get Started](#-quick-start) ยท [Project Structure](./docs/PROJECT_STRUCTURE.md) ยท [Backend Docs](./docs/BACKEND.md) ยท [Examples](./examples/) ยท [Report Bug](https://github.com/ROHIT8759/rkk-next/issues)
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
- โ
Intelligent route prefetching (hover-based)
|
|
24
|
-
- โ
Network-aware prefetching
|
|
25
|
-
- โ
Route change observer with performance metrics
|
|
26
|
-
- โ
Analytics-ready routing events
|
|
20
|
+
</div>
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
- โ
Lazy loading for heavy components
|
|
30
|
-
- โ
Optimized image wrapper (SEO + performance)
|
|
31
|
-
- โ
Cache & CDN header presets
|
|
32
|
-
- โ
Edge-friendly caching strategies
|
|
33
|
-
- โ
Security headers included
|
|
22
|
+
---
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
- โ
Web Vitals tracking (LCP, FID, CLS, etc.)
|
|
37
|
-
- โ
Route navigation analytics
|
|
38
|
-
- โ
Performance monitoring
|
|
24
|
+
## ๐ฏ Why rkk-next?
|
|
39
25
|
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
Building performant, SEO-optimized Next.js applications requires juggling multiple concerns: meta tags, structured data, route prefetching, image optimization, and caching strategies. **rkk-next** provides production-tested solutions out of the box.
|
|
27
|
+
|
|
28
|
+
**Perfect for:**
|
|
29
|
+
|
|
30
|
+
- ๐ Startups needing rapid development
|
|
31
|
+
- ๐ผ Enterprise applications requiring SEO excellence
|
|
32
|
+
- ๐จ Marketing websites and landing pages
|
|
33
|
+
- ๐ Web3 dashboards and SaaS platforms
|
|
34
|
+
- โก Performance-critical applications
|
|
35
|
+
|
|
36
|
+
## โจ Key Features
|
|
37
|
+
|
|
38
|
+
<table>
|
|
39
|
+
<tr>
|
|
40
|
+
<td width="50%">
|
|
41
|
+
|
|
42
|
+
### ๐ **SEO Excellence**
|
|
43
|
+
|
|
44
|
+
- Comprehensive meta tag management
|
|
45
|
+
- OpenGraph & Twitter Cards
|
|
46
|
+
- JSON-LD structured data (Schema.org)
|
|
47
|
+
- Automatic canonical URLs
|
|
48
|
+
- Server-side rendering optimized
|
|
49
|
+
|
|
50
|
+
</td>
|
|
51
|
+
<td width="50%">
|
|
52
|
+
|
|
53
|
+
### โก **Performance First**
|
|
54
|
+
|
|
55
|
+
- Intelligent route prefetching
|
|
56
|
+
- Network-aware optimizations
|
|
57
|
+
- Lazy loading for heavy components
|
|
58
|
+
- CDN & edge caching strategies
|
|
59
|
+
- Built-in security headers
|
|
60
|
+
|
|
61
|
+
</td>
|
|
62
|
+
</tr>
|
|
63
|
+
<tr>
|
|
64
|
+
<td width="50%">
|
|
65
|
+
|
|
66
|
+
### ๐ **Analytics Ready**
|
|
67
|
+
|
|
68
|
+
- Core Web Vitals tracking
|
|
69
|
+
- Route navigation metrics
|
|
70
|
+
- Performance monitoring
|
|
71
|
+
- Custom event tracking
|
|
72
|
+
- Production-ready insights
|
|
73
|
+
|
|
74
|
+
</td>
|
|
75
|
+
<td width="50%">
|
|
76
|
+
|
|
77
|
+
### โก **Backend Utilities**
|
|
78
|
+
|
|
79
|
+
- Express-like middleware
|
|
80
|
+
- API route optimization
|
|
81
|
+
- Rate limiting & CORS
|
|
82
|
+
- Response caching
|
|
83
|
+
- Request validation
|
|
84
|
+
|
|
85
|
+
</td>
|
|
86
|
+
</tr>
|
|
87
|
+
<tr>
|
|
88
|
+
<td width="50%">
|
|
89
|
+
|
|
90
|
+
### ๐จ **Developer Experience**
|
|
91
|
+
|
|
92
|
+
- Full TypeScript support
|
|
93
|
+
- Zero configuration needed
|
|
94
|
+
- Pages Router & App Router
|
|
95
|
+
- Comprehensive documentation
|
|
96
|
+
- Active maintenance
|
|
97
|
+
|
|
98
|
+
</td>
|
|
99
|
+
</tr>
|
|
100
|
+
</table>
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## ๐ Quick Start
|
|
105
|
+
|
|
106
|
+
### Create New Project (Recommended)
|
|
42
107
|
|
|
108
|
+
Get started instantly with our CLI tool:
|
|
43
109
|
|
|
44
|
-
|
|
110
|
+
```bash
|
|
111
|
+
npx create-next-rkk@latest my-app
|
|
112
|
+
cd my-app
|
|
113
|
+
npm run dev
|
|
114
|
+
```
|
|
45
115
|
|
|
116
|
+
### Add to Existing Project
|
|
117
|
+
|
|
118
|
+
Install into your existing Next.js application:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm install rkk-next
|
|
122
|
+
# or
|
|
46
123
|
yarn add rkk-next
|
|
124
|
+
# or
|
|
125
|
+
pnpm add rkk-next
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## ๐ Usage Examples
|
|
131
|
+
|
|
132
|
+
### SEO Meta Management
|
|
47
133
|
|
|
48
|
-
|
|
49
|
-
|
|
134
|
+
Centralize your SEO configuration with type-safe components:
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
50
137
|
import { MetaManager } from "rkk-next";
|
|
51
138
|
|
|
52
|
-
export default function
|
|
139
|
+
export default function HomePage() {
|
|
53
140
|
return (
|
|
54
141
|
<>
|
|
55
142
|
<MetaManager
|
|
56
143
|
title="Home | My App"
|
|
57
|
-
description="
|
|
58
|
-
keywords="Next.js, SEO, Performance"
|
|
59
|
-
image="/og.png"
|
|
144
|
+
description="Production-ready Next.js application with enterprise SEO"
|
|
145
|
+
keywords="Next.js, React, SEO, Performance"
|
|
146
|
+
image="https://myapp.com/og-image.png"
|
|
60
147
|
siteName="My App"
|
|
148
|
+
twitterHandle="myhandle"
|
|
61
149
|
/>
|
|
62
150
|
|
|
63
|
-
<
|
|
151
|
+
<main>{/* Your content */}</main>
|
|
64
152
|
</>
|
|
65
153
|
);
|
|
66
154
|
}
|
|
155
|
+
```
|
|
67
156
|
|
|
68
|
-
|
|
69
|
-
import { JsonLd } from "rkk-next";
|
|
157
|
+
### Structured Data (JSON-LD)
|
|
70
158
|
|
|
71
|
-
|
|
72
|
-
type="WebSite"
|
|
73
|
-
data={{
|
|
74
|
-
name: "My App",
|
|
75
|
-
url: "https://myapp.com",
|
|
76
|
-
}}
|
|
77
|
-
/>
|
|
159
|
+
Improve search engine understanding with structured data:
|
|
78
160
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
import { SmartLink } from "rkk-next";
|
|
161
|
+
```tsx
|
|
162
|
+
import { JsonLd } from "rkk-next";
|
|
82
163
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
164
|
+
export default function ArticlePage() {
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
<JsonLd
|
|
168
|
+
type="Article"
|
|
169
|
+
data={{
|
|
170
|
+
headline: "Advanced Next.js SEO Techniques",
|
|
171
|
+
image: "https://myapp.com/article.jpg",
|
|
172
|
+
datePublished: "2025-12-18T08:00:00.000Z",
|
|
173
|
+
author: {
|
|
174
|
+
"@type": "Person",
|
|
175
|
+
name: "John Doe",
|
|
176
|
+
},
|
|
177
|
+
}}
|
|
178
|
+
/>
|
|
86
179
|
|
|
180
|
+
<article>{/* Article content */}</article>
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
87
185
|
|
|
88
|
-
|
|
89
|
-
โ Network-aware
|
|
90
|
-
โ SEO-safe <a> tag
|
|
186
|
+
### Smart Routing & Prefetching
|
|
91
187
|
|
|
92
|
-
|
|
93
|
-
import { observeRoutes } from "rkk-next";
|
|
188
|
+
Enhance navigation performance with intelligent prefetching:
|
|
94
189
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
190
|
+
```tsx
|
|
191
|
+
import { SmartLink, observeRoutes } from "rkk-next";
|
|
192
|
+
import { useEffect } from "react";
|
|
98
193
|
|
|
99
|
-
|
|
100
|
-
|
|
194
|
+
export default function Navigation() {
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
// Track route changes for analytics
|
|
197
|
+
const unsubscribe = observeRoutes((event) => {
|
|
198
|
+
analytics.track("page_view", {
|
|
199
|
+
url: event.url,
|
|
200
|
+
duration: event.duration,
|
|
201
|
+
});
|
|
202
|
+
});
|
|
101
203
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
alt="Landing page hero image"
|
|
105
|
-
width={1200}
|
|
106
|
-
height={630}
|
|
107
|
-
priority
|
|
108
|
-
/>
|
|
204
|
+
return unsubscribe;
|
|
205
|
+
}, []);
|
|
109
206
|
|
|
207
|
+
return (
|
|
208
|
+
<nav>
|
|
209
|
+
<SmartLink href="/products" prefetchOnHover>
|
|
210
|
+
Products
|
|
211
|
+
</SmartLink>
|
|
212
|
+
</nav>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
110
216
|
|
|
111
|
-
|
|
112
|
-
โ Responsive sizes
|
|
113
|
-
โ LCP optimized
|
|
217
|
+
### Optimized Images
|
|
114
218
|
|
|
115
|
-
|
|
116
|
-
import { lazyImport } from "rkk-next";
|
|
219
|
+
Ensure SEO-compliant and performant images:
|
|
117
220
|
|
|
118
|
-
|
|
221
|
+
```tsx
|
|
222
|
+
import { OptimizedImage } from "rkk-next";
|
|
119
223
|
|
|
120
|
-
export default function
|
|
121
|
-
return
|
|
224
|
+
export default function Hero() {
|
|
225
|
+
return (
|
|
226
|
+
<OptimizedImage
|
|
227
|
+
src="/hero-banner.jpg"
|
|
228
|
+
alt="Professional hero banner showcasing our product"
|
|
229
|
+
width={1920}
|
|
230
|
+
height={1080}
|
|
231
|
+
priority // For above-the-fold images
|
|
232
|
+
quality={85}
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
122
235
|
}
|
|
236
|
+
```
|
|
123
237
|
|
|
124
|
-
|
|
125
|
-
import { prefetchRoute, isFastConnection } from "rkk-next";
|
|
238
|
+
### Code Splitting & Lazy Loading
|
|
126
239
|
|
|
127
|
-
|
|
128
|
-
|
|
240
|
+
Reduce initial bundle size with intelligent lazy loading:
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
import { lazyImport, DefaultLoader } from "rkk-next";
|
|
244
|
+
|
|
245
|
+
// Heavy component loaded on-demand
|
|
246
|
+
const AnalyticsDashboard = lazyImport(() => import("./AnalyticsDashboard"), {
|
|
247
|
+
loading: DefaultLoader,
|
|
248
|
+
ssr: false,
|
|
249
|
+
delay: 100,
|
|
129
250
|
});
|
|
130
251
|
|
|
131
|
-
|
|
252
|
+
export default function Dashboard() {
|
|
253
|
+
return (
|
|
254
|
+
<main>
|
|
255
|
+
<h1>Dashboard</h1>
|
|
256
|
+
<AnalyticsDashboard />
|
|
257
|
+
</main>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Performance-Optimized Caching
|
|
132
263
|
|
|
133
|
-
|
|
264
|
+
Configure production-grade caching in `next.config.js`:
|
|
134
265
|
|
|
266
|
+
```javascript
|
|
135
267
|
const {
|
|
136
268
|
LONG_TERM_CACHE,
|
|
137
269
|
EDGE_CACHE,
|
|
138
270
|
NO_CACHE,
|
|
271
|
+
SECURITY_HEADERS,
|
|
139
272
|
applyCache,
|
|
140
|
-
} = require("rkk-next");
|
|
273
|
+
} = require("rkk-next/performance/cacheHeaders");
|
|
141
274
|
|
|
142
275
|
module.exports = {
|
|
143
276
|
async headers() {
|
|
144
277
|
return [
|
|
278
|
+
// Static assets: aggressive caching
|
|
145
279
|
applyCache("/_next/static/:path*", LONG_TERM_CACHE),
|
|
280
|
+
applyCache("/images/:path*", LONG_TERM_CACHE),
|
|
281
|
+
|
|
282
|
+
// API routes: edge caching
|
|
146
283
|
applyCache("/api/public/:path*", EDGE_CACHE),
|
|
284
|
+
|
|
285
|
+
// User-specific pages: no cache
|
|
147
286
|
applyCache("/dashboard/:path*", NO_CACHE),
|
|
287
|
+
|
|
288
|
+
// Security headers for all routes
|
|
289
|
+
{
|
|
290
|
+
source: "/:path*",
|
|
291
|
+
headers: SECURITY_HEADERS,
|
|
292
|
+
},
|
|
148
293
|
];
|
|
149
294
|
},
|
|
150
295
|
};
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Backend API Utilities
|
|
299
|
+
|
|
300
|
+
Build robust Next.js API routes with Express-like middleware:
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
// pages/api/users/[id].ts
|
|
304
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
305
|
+
import {
|
|
306
|
+
composeMiddleware,
|
|
307
|
+
cors,
|
|
308
|
+
rateLimit,
|
|
309
|
+
validateRequest,
|
|
310
|
+
logger,
|
|
311
|
+
errorHandler,
|
|
312
|
+
cacheResponse,
|
|
313
|
+
jsonResponse,
|
|
314
|
+
allowMethods,
|
|
315
|
+
} from "rkk-next";
|
|
316
|
+
|
|
317
|
+
// Compose middleware chain
|
|
318
|
+
const handler = composeMiddleware(
|
|
319
|
+
cors({ origin: "https://yourdomain.com" }),
|
|
320
|
+
rateLimit({ maxRequests: 100, windowMs: 60000 }),
|
|
321
|
+
logger(),
|
|
322
|
+
allowMethods(["GET", "PUT", "DELETE"]),
|
|
323
|
+
cacheResponse({ ttl: 300 }), // Cache for 5 minutes
|
|
324
|
+
validateRequest((req) => {
|
|
325
|
+
if (req.method === "PUT" && !req.body.name) {
|
|
326
|
+
return "Name is required";
|
|
327
|
+
}
|
|
328
|
+
}),
|
|
329
|
+
errorHandler()
|
|
330
|
+
)(async (req: NextApiRequest, res: NextApiResponse) => {
|
|
331
|
+
const { id } = req.query;
|
|
332
|
+
|
|
333
|
+
// Your API logic
|
|
334
|
+
const user = await getUserById(id as string);
|
|
335
|
+
|
|
336
|
+
return jsonResponse(res, {
|
|
337
|
+
success: true,
|
|
338
|
+
data: user,
|
|
339
|
+
});
|
|
340
|
+
});
|
|
151
341
|
|
|
152
|
-
|
|
342
|
+
export default handler;
|
|
343
|
+
```
|
|
153
344
|
|
|
154
|
-
|
|
155
|
-
|-------------------|--------------|------------|
|
|
156
|
-
| MetaManager | โ
| โ
(via generateAppMetadata) |
|
|
157
|
-
| JsonLd | โ
| โ
|
|
|
158
|
-
| SmartLink | โ
| โ ๏ธ (use for internal links only) |
|
|
159
|
-
| Routing Observer | โ
| โ ๏ธ (Pages Router recommended) |
|
|
160
|
-
| OptimizedImage | โ
| โ
|
|
|
161
|
-
| Lazy Loading | โ
| โ
|
|
|
162
|
-
| Cache Headers | โ
| โ
|
|
|
163
|
-
| Web Vitals | โ
| โ
|
|
|
345
|
+
**Server-side caching with automatic TTL:**
|
|
164
346
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- React >= 17.0.0
|
|
168
|
-
- TypeScript >= 4.5.0 (optional but recommended)
|
|
169
|
-
๐ ๏ธ Best Practices
|
|
347
|
+
```typescript
|
|
348
|
+
import { cache, memoize } from "rkk-next";
|
|
170
349
|
|
|
171
|
-
|
|
350
|
+
// Cache expensive operations
|
|
351
|
+
const expensiveQuery = memoize(
|
|
352
|
+
async (userId: string) => {
|
|
353
|
+
return await database.query(/* ... */);
|
|
354
|
+
},
|
|
355
|
+
{ ttl: 600 } // 10 minutes
|
|
356
|
+
);
|
|
172
357
|
|
|
173
|
-
|
|
358
|
+
// Manual cache control
|
|
359
|
+
cache.set("user:123", userData, 300);
|
|
360
|
+
const cachedUser = cache.get("user:123");
|
|
361
|
+
```
|
|
174
362
|
|
|
175
|
-
|
|
363
|
+
See [Backend Utilities Documentation](docs/BACKEND.md) for complete API reference.
|
|
176
364
|
|
|
177
|
-
|
|
365
|
+
---
|
|
178
366
|
|
|
179
|
-
|
|
367
|
+
## ๐งฉ Compatibility Matrix
|
|
180
368
|
|
|
181
|
-
|
|
369
|
+
| Feature | Pages Router | App Router | Notes |
|
|
370
|
+
| -------------- | :----------: | :--------: | ------------------------------------- |
|
|
371
|
+
| MetaManager | โ
| โ
| App Router uses `generateAppMetadata` |
|
|
372
|
+
| JsonLd | โ
| โ
| Works with both routers |
|
|
373
|
+
| SmartLink | โ
| โ ๏ธ | Recommended for Pages Router |
|
|
374
|
+
| RouteObserver | โ
| โ ๏ธ | Pages Router only |
|
|
375
|
+
| OptimizedImage | โ
| โ
| Full support both routers |
|
|
376
|
+
| Lazy Loading | โ
| โ
| Dynamic imports supported |
|
|
377
|
+
| Cache Headers | โ
| โ
| Universal support |
|
|
378
|
+
| Web Vitals | โ
| โ
| Analytics integration |
|
|
379
|
+
| Backend Utils | โ
| โ
| API routes middleware |
|
|
182
380
|
|
|
183
|
-
**
|
|
184
|
-
|
|
185
|
-
|
|
381
|
+
**System Requirements:**
|
|
382
|
+
|
|
383
|
+
- Next.js `>= 12.0.0`
|
|
384
|
+
- React `>= 17.0.0`
|
|
385
|
+
- Node.js `>= 16.0.0`
|
|
386
|
+
- TypeScript `>= 4.5.0` (optional but recommended)
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## ๐ Learn More
|
|
186
391
|
|
|
187
|
-
|
|
392
|
+
### ๐ Documentation
|
|
188
393
|
|
|
189
|
-
-
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
-
|
|
394
|
+
- [Complete Documentation](./docs/DOCS.md) - Comprehensive API reference
|
|
395
|
+
- [Quick Start Guide](./docs/QUICKSTART.md) - Get running in 5 minutes
|
|
396
|
+
- [Migration Guide](./docs/DOCS.md) - Upgrade from other solutions
|
|
397
|
+
- [Best Practices](./docs/DOCS.md#best-practices) - Production tips
|
|
193
398
|
|
|
194
399
|
## ๐ค Contributing
|
|
195
400
|
|
|
196
|
-
We welcome contributions
|
|
401
|
+
We welcome contributions from the community! Whether it's:
|
|
402
|
+
|
|
403
|
+
- ๐ Bug reports and fixes
|
|
404
|
+
- โจ New features and enhancements
|
|
405
|
+
- ๐ Documentation improvements
|
|
406
|
+
- ๐ก Feature suggestions
|
|
407
|
+
|
|
408
|
+
**Getting Started:**
|
|
197
409
|
|
|
198
410
|
1. Fork the repository
|
|
199
|
-
2. Create
|
|
200
|
-
3.
|
|
201
|
-
4.
|
|
202
|
-
5.
|
|
411
|
+
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
|
412
|
+
3. Make your changes with clear commit messages
|
|
413
|
+
4. Write or update tests as needed
|
|
414
|
+
5. Submit a pull request
|
|
415
|
+
|
|
416
|
+
See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for detailed guidelines.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## ๐ Project Structure
|
|
203
421
|
|
|
204
|
-
|
|
422
|
+
```
|
|
423
|
+
rkk-next/
|
|
424
|
+
โโโ src/ # Source code
|
|
425
|
+
โ โโโ seo/ # SEO utilities
|
|
426
|
+
โ โโโ routing/ # Routing optimization
|
|
427
|
+
โ โโโ performance/ # Performance tools
|
|
428
|
+
โ โโโ analytics/ # Web Vitals tracking
|
|
429
|
+
โ โโโ backend/ # API utilities
|
|
430
|
+
โโโ __tests__/ # Test suites (97 tests)
|
|
431
|
+
โโโ docs/ # Documentation
|
|
432
|
+
โโโ examples/ # Usage examples
|
|
433
|
+
โโโ cli/ # CLI tool (create-next-rkk)
|
|
434
|
+
```
|
|
205
435
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
- [ ] Add Lighthouse CI integration
|
|
210
|
-
- [ ] Video tutorials & guides
|
|
436
|
+
๐ See [Project Structure Documentation](./docs/PROJECT_STRUCTURE.md) for complete details.
|
|
437
|
+
|
|
438
|
+
---
|
|
211
439
|
|
|
212
440
|
## ๐ License
|
|
213
441
|
|
|
214
442
|
MIT License ยฉ 2025 [Rohit Kumar Kundu](https://github.com/ROHIT8759)
|
|
215
443
|
|
|
444
|
+
Free for commercial and personal use. See [LICENSE](./LICENSE) for details.
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
## ๐ Support & Community
|
|
449
|
+
|
|
450
|
+
### Get Help
|
|
451
|
+
|
|
452
|
+
- ๐ [Documentation](./docs/DOCS.md)
|
|
453
|
+
- ๐ฌ [GitHub Discussions](https://github.com/ROHIT8759/rkk-next/discussions)
|
|
454
|
+
- ๐ [Issue Tracker](https://github.com/ROHIT8759/rkk-next/issues)
|
|
455
|
+
|
|
456
|
+
### Show Your Support
|
|
457
|
+
|
|
458
|
+
If rkk-next helps your project:
|
|
459
|
+
|
|
460
|
+
- โญ Star the repository
|
|
461
|
+
- ๐ฆ Share on social media
|
|
462
|
+
- ๐ Write about your experience
|
|
463
|
+
- ๐ค Contribute back to the project
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
## ๐งโ๐ป Author
|
|
468
|
+
|
|
469
|
+
**Rohit Kumar Kundu**
|
|
470
|
+
Full-Stack Developer | Next.js & Web3 Specialist
|
|
471
|
+
|
|
472
|
+
๐ [GitHub](https://github.com/ROHIT8759) ยท [LinkedIn](https://linkedin.com/in/rohit-kumar-kundu) ยท [Portfolio](https://rohitkundu.dev)
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
<div align="center">
|
|
477
|
+
|
|
478
|
+
**Built with โค๏ธ for the Next.js community**
|
|
479
|
+
|
|
480
|
+
[Get Started](./docs/QUICKSTART.md) ยท [Documentation](./docs/DOCS.md) ยท [Examples](./examples/) ยท [Changelog](./CHANGELOG.md)
|
|
481
|
+
|
|
482
|
+
</div>
|
|
483
|
+
MIT License ยฉ 2025 [Rohit Kumar Kundu](https://github.com/ROHIT8759)
|
|
484
|
+
|
|
216
485
|
Free to use, modify, and distribute. See [LICENSE](./LICENSE) for details.
|
|
217
486
|
|
|
218
487
|
## โญ Support the Project
|
|
@@ -245,4 +514,4 @@ If you want, I can now:
|
|
|
245
514
|
|
|
246
515
|
โ Final SDK audit before release
|
|
247
516
|
|
|
248
|
-
Just tell me ๐
|
|
517
|
+
Just tell me ๐
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
export interface CacheOptions {
|
|
3
|
+
/** Time to live in seconds */
|
|
4
|
+
ttl?: number;
|
|
5
|
+
/** Cache key generator function */
|
|
6
|
+
keyGenerator?: (req: NextApiRequest) => string;
|
|
7
|
+
/** Conditional caching based on request */
|
|
8
|
+
shouldCache?: (req: NextApiRequest) => boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* In-memory cache store for API responses
|
|
12
|
+
*/
|
|
13
|
+
declare class MemoryCache {
|
|
14
|
+
private cache;
|
|
15
|
+
set<T = any>(key: string, data: T, ttl: number): void;
|
|
16
|
+
get<T = any>(key: string): T | null;
|
|
17
|
+
has(key: string): boolean;
|
|
18
|
+
delete(key: string): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
size(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Clean up expired entries
|
|
23
|
+
*/
|
|
24
|
+
cleanup(): void;
|
|
25
|
+
}
|
|
26
|
+
export declare const cache: MemoryCache;
|
|
27
|
+
/**
|
|
28
|
+
* Cache API response middleware
|
|
29
|
+
*/
|
|
30
|
+
export declare function cacheResponse(options?: CacheOptions): (req: NextApiRequest, res: NextApiResponse, next: () => void | Promise<void>) => Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Invalidate cache by pattern or specific key
|
|
33
|
+
*/
|
|
34
|
+
export declare function invalidateCache(pattern?: string | RegExp): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get cache statistics
|
|
37
|
+
*/
|
|
38
|
+
export declare function getCacheStats(): {
|
|
39
|
+
size: number;
|
|
40
|
+
timestamp: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Memoize function results with TTL
|
|
44
|
+
*/
|
|
45
|
+
export declare function memoize<T extends (...args: any[]) => any>(fn: T, options?: {
|
|
46
|
+
ttl?: number;
|
|
47
|
+
keyGenerator?: (...args: Parameters<T>) => string;
|
|
48
|
+
}): T;
|
|
49
|
+
export {};
|