Skip to content

Instantly share code, notes, and snippets.

View dinhkhanh's full-sized avatar

Tran Dinh Khanh dinhkhanh

View GitHub Profile

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

@dinhkhanh
dinhkhanh / proximity-prefetch.tsx
Created April 6, 2025 07:43 — forked from pontusab/proximity-prefetch.tsx
Next.js Proximity Prefetch (PPF)
"use client";
import { useRouter } from "next/navigation";
import type { ReactNode } from "react";
import { useCallback, useEffect, useState } from "react";
interface ProximityPrefetchProps {
children: ReactNode;
threshold?: number;
predictionInterval?: number;