Loading...
Loading...
Senior specialist in Next.js 16.1.1, React 19.2, and Gemini Elite Standards. Focus on Proxy & Cache paradigm and PPR.
npx skill4agent add yuniorglez/gemini-elite-core next16-expertmiddleware.tsproxy.tsproxy.tsuse cachenpx create-next-app@latest my-elite-app \
--typescript \
--tailwind \
--eslint \
--app \
--src-dir \
--import-alias "@/*"next.config.tsimport type { NextConfig } from "next";
const nextConfig: NextConfig = {
experimental: {
ppr: true, // Enable Partial Pre-rendering
dynamicIO: true, // New IO optimization for Next.js 16
reactCompiler: true, // Stable React Compiler support
},
logging: {
fetches: {
fullUrl: true,
},
},
};
export default nextConfig;proxy.tsmiddleware.tsproxy.tssrc/app/proxy.tsimport { nextProxy } from 'next/server';
export default nextProxy(async (request) => {
const url = request.nextUrl;
// Global Routing Logic
if (url.pathname.startsWith('/api/v1')) {
// Standardize API versioning at the proxy level
}
// Security Headers & Request Decoration
request.headers.set('X-Elite-Engine', '16.1.1');
const response = await fetch(request);
// Performance Monitoring
response.headers.set('Server-Timing', 'elite;dur=20');
return response;
});use cacheuse cacherevalidatePathsrc/services/data.tsimport { cacheLife, cacheTag } from 'next/cache';
export async function getGlobalMetrics() {
'use cache';
cacheLife(60); // Cache for 60 seconds
cacheTag('metrics');
const data = await fetch('https://api.internal/metrics').then(r => r.json());
return data;
}revalidateTag('metrics')updateTag('metrics')useActionState'use client';
import { useActionState } from 'react';
import { signUpAction } from '@/actions/auth';
export function SignUpForm() {
const [state, action, isPending] = useActionState(signUpAction, null);
return (
<form action={action}>
<input name="email" type="email" required />
{state?.errors?.email && <p className="text-red-500">{state.errors.email}</p>}
<button disabled={isPending}>
{isPending ? 'Processing...' : 'Sign Up'}
</button>
</form>
);
}<Activity />import { Activity } from 'react';
export function TabSystem({ activeTab }) {
return (
<>
<Activity mode={activeTab === 'home' ? 'visible' : 'hidden'}>
<HomeTab />
</Activity>
<Activity mode={activeTab === 'settings' ? 'visible' : 'hidden'}>
<SettingsTab />
</Activity>
</>
);
}// app/dashboard/page.tsx
import { getGlobalMetrics } from '@/services/data';
export default async function Page() {
const metrics = await getGlobalMetrics(); // Direct, cached call
return (
<div>
<h1>Dashboard</h1>
<pre>{JSON.stringify(metrics, null, 2)}</pre>
</div>
);
}// actions/auth.ts
'use server';
import { updateTag } from 'next/cache';
export async function signUpAction(prevState: any, formData: FormData) {
const email = formData.get('email');
try {
await db.user.create({ data: { email } });
updateTag('users'); // Background revalidation
return { success: true };
} catch (e) {
return { errors: { email: 'Invalid email' } };
}
}hooks/services/'use client';
import { useState, useEffect } from 'react';
export function SafeClientComponent({ children }) {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) return <div className="animate-pulse" />; // Placeholder
return <>{children}</>;
}middleware.tsproxy.tsmiddleware.tsrevalidatePathupdateTagcookies()headers()<Suspense>index.tsproxy.tsuse cache