Public Pages Structure
The public directory contains all pages that are accessible without authentication. These routes are available to anyone visiting your application, even if they are not logged in.
Your folder structure should look like this:
app/
└── (public)/ → Publicly accessible pages
├── (docs)/ → Documentation pages (e.g., API, guides)
├── (landing)/ → Marketing and landing pages
├── privacy/ → Privacy Policy (static legal page)
└── terms/ → Terms of Service (static legal page)
Purpose of the (public) Folder
The (public) folder is designed to host all routes that can be viewed by unauthenticated users.
These typically include:
- Marketing or landing pages (e.g., home, pricing, features)
- Documentation pages for your SaaS or API
- Legal pages like Privacy Policy and Terms of Service
- Contact or About pages
Any user — whether logged in or not — can access these URLs directly.
Recommended Structure and Best Practices
- Keep marketing and onboarding content under
app/(public)/(landing)/Example:app/(public)/(landing)/page.tsx - Place documentation under
app/(public)/(docs)/ - Store compliance pages under
app/(public)/privacy/andapp/(public)/terms/ - If you need nested sections (e.g.,
/docs/getting-started), organize them within(docs)as subfolders.
Linking to Public Pages
Since these routes are part of the Next.js app router, you can link to them using:
import Link from "next/link";
export default function Footer() {
return (
<footer>
<Link href="/privacy">Privacy Policy</Link>
<Link href="/terms">Terms of Service</Link>
<Link href="/docs">Documentation</Link>
</footer>
);
}
This ensures your public legal and informational pages are always accessible from key areas like your site footer, landing page, or checkout flow.
4. Compliance Note
Stripe and most payment providers require that your Privacy Policy and Terms of Service be publicly accessible.
Ensure they remain under the (public) directory so they can be reached without login barriers.
✅ Summary:
All routes within app/(public)/ are open to everyone, making them ideal for marketing, onboarding, documentation, and compliance-related pages.