📂 Public Directory (public/)
Static asset delivery in Dinou. Learn how the public/ directory serves favicons, robots.txt, sitemaps, and domain verification files directly from .dinou/dist3 without passing through bundlers.
1. Overview & ArchitectureStatic Filesystem
Dinou provides a dedicated public/ folder located at the root of your project (parallel to src/ and package.json). This directory is the single home for all static files that must be accessible at fixed, unhashed URLs on the root path (/).
Bypassing Bundlers (Direct Copy to .dinou/dist3)
Unlike application code, stylesheets, or imported media which are parsed and bundled by Webpack, Rollup, or Esbuild, files placed in public/ completely bypass the bundler pipeline:
dinou dev)Dinou's dev server intercepts static file requests matching paths in public/ and streams them instantly from disk with zero build step, hot-reloading, or cache latency.
dinou build)During the build process (across Esbuild, Rollup, and Webpack), Dinou executes a direct recursive copy from ./public into .dinou/dist3, preserving nested subdirectories and .well-known/ files with accurate Content-Type and Cache-Control headers.
Why Bypassing the Bundler Matters
Third-party crawlers, browsers, and verification bots require exact, unchanging file paths like /robots.txt, /favicon.ico, or /google12345.html. If these passed through a bundler, they would be renamed with content hashes (e.g. robots.a7b9c.txt) or inlined as data URIs, breaking external protocol compliance.
Recommended Directory Structure
Here is the standard layout of a production Dinou project using the public/ folder:
my-dinou-app/
├── public/
│ ├── favicon.ico # Legacy & fallback browser favicon
│ ├── favicon-16x16.png # Small tab icon
│ ├── favicon-32x32.png # Standard tab icon
│ ├── apple-touch-icon.png # iOS home screen bookmark icon (180x180)
│ ├── site.webmanifest # Progressive Web App (PWA) manifest
│ ├── robots.txt # Web crawler instructions
│ ├── sitemap.xml # Search engine sitemap index
│ ├── googlea1b2c3d4e5f6.html # Google Search Console domain verification
│ ├── .well-known/ # Mobile app links & security metadata
│ │ ├── assetlinks.json # Android App Links
│ │ └── apple-app-site-association # iOS Universal Links
│ └── images/
│ ├── og-image.png # OpenGraph / Twitter social card
│ └── logo-transparent.png # Unbundled high-res brand marks
├── src/
│ ├── layout.tsx # Root HTML shell linking public assets
│ └── page.tsx # Root route (/)
├── dinou.config.ts
└── package.json2. URL Mapping & Multi-Runtime ServingZero-RSC Fast Path
Every file and nested folder inside public/ is served directly from the root URL (/). You must never include /public/ in the URL path. URL-encoded filenames (such as spaces in /docs/brochure%202026.pdf) are automatically decoded and confined safely within the static root.
| Filesystem Path | Public URL Path | Status |
|---|---|---|
| public/favicon.ico | /favicon.ico | ✓ Correct |
| public/robots.txt | /robots.txt | ✓ Correct |
| public/images/og-image.png | /images/og-image.png | ✓ Correct |
| public/.well-known/assetlinks.json | /.well-known/assetlinks.json | ✓ Correct |
| public/favicon.ico | /public/favicon.ico | ✗ 404 Not Found |
Multi-Runtime Delivery & Cache-Control Policy
In production, Dinou intercepts GET and HEAD static asset requests before invoking the React Server Components engine across every deployment target (see Deployment):
- Node.js: Streamed directly from
.dinou/dist3via zero-copyReadable.toWeb(fs.createReadStream(...))with full HTTP byte-range support (Accept-Ranges: bytes/206 Partial Contentfor video, audio, and PDFs). - Bun: Served via kernel-level zero-copy
Bun.file()(including byte-range slicing viafile.slice(...)). - Deno: Delivered directly from
.dinou/dist3insideDeno.servewith full HTTP byte-range support. - Cloudflare Workers: Copied cleanly into
.dinou/cloudflare/assetsand served at the edge through theenv.ASSETSstatic binding (including/.well-known/*,/sitemap.xml, standalone verification.htmlfiles, PDFs, and media) without waking the RSC renderer, while internal SSG/ISR cache files remain isolated inside.dinou/cloudflare/assets/__dinou_dist2. - Netlify (Functions v2): Published directly from
.dinou/dist3to Netlify's global edge CDN (publish = ".dinou/dist3"). Dinou's serverless handler setspreferStatic: true, so static assets inpublic/and hashed chunks are served straight from the edge without invoking the SSR function. - Static Export (
dinou export-static): Copiespublic/assets and hashed client bundles from.dinou/dist3alongside pre-rendered SSGindex.html,page.rsc, andlayout.rscfiles from.dinou/dist2intoout/for full client-side SPA navigation on pure static hosts, while automatically excluding internal ISR/PPR/Slot cache metadata.
Smart Cache-Control & Path Hardening
Because files in public/ have fixed, unhashed filenames, Dinou serves them with Cache-Control: public, max-age=0, must-revalidate so updates to /sitemap.xml, /robots.txt, or /images/og-image.png take effect immediately on redeploy. Content-hashed build outputs (/assets/* and hashed bundler chunks) automatically receive Cache-Control: public, max-age=31536000, immutable.
Server bundles and internal build manifests are physically isolated in .dinou/dist1 so .dinou/dist3 remains a pure public static webroot (meaning you can also place a PWA public/manifest.json in public/ without naming conflicts). Hidden dotfiles (such as .env or .git) are strictly blocked from public HTTP access, while RFC 8615 /.well-known/* routes remain publicly reachable.
3. Common Use CasesGuides
Favicons & App Icons
To provide branding across desktop browsers, mobile devices, and PWA home-screen bookmarks:
- Generate your icon bundle using a standard tool (like favicon.io or RealFaviconGenerator).
- Place the generated icon files directly in
public/. - Reference them in your Root Layout (
src/layout.tsx) inside the<head>element (alongside your global stylesheet—see Styles):
// src/layout.tsx
import type { ReactNode } from "react";
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<head>
<title>My Dinou Application</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
{/* Favicon & Multi-Resolution App Icons */}
<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
{/* Global Styles */}
<link href="/styles.css" rel="stylesheet" precedence="default" />
</head>
<body>{children}</body>
</html>
);
}robots.txt & sitemap.xml (SEO)
Search engine bots like Googlebot expect crawler instructions and sitemaps at standard URLs. Create public/robots.txt:
# public/robots.txt
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /api/private/
# Sitemap location
Sitemap: https://mydinouapp.com/sitemap.xmlAnd create your static sitemap index at public/sitemap.xml:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://mydinouapp.com/</loc>
<lastmod>2026-10-01</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://mydinouapp.com/docs</loc>
<lastmod>2026-10-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>Domain Verification & .well-known
Domain ownership verification files (Google Search Console, Apple Pay, Pinterest, Bing) can be dropped straight into public/:
# Google Search Console verification:
# Placed in: public/google1a2b3c4d5e6f.html
# Accessible at: https://mydinouapp.com/google1a2b3c4d5e6f.htmlFor mobile deep-linking protocols (Universal Links on iOS and App Links on Android), create a .well-known directory inside public/. Dinou automatically serves extensionless apple-app-site-association files with Content-Type: application/json; charset=utf-8 as required by Apple's Universal Links specification:
# Apple Universal Links:
public/.well-known/apple-app-site-association -> https://mydinouapp.com/.well-known/apple-app-site-association
# Android App Links:
public/.well-known/assetlinks.json -> https://mydinouapp.com/.well-known/assetlinks.json4. public/ vs. Imported Assets (src/)Architecture Comparison
Dinou provides two distinct mechanisms for handling assets: unbundled static files in public/ and bundler-imported modules in Imported Assets (src/). Choose the right pattern for your use case:
| Feature | Static Directory (public/) | Imported Assets (src/) |
|---|---|---|
| Filesystem Location | ./public/**/* | ./src/**/* |
| Bundler Processing | None (Bypasses bundlers entirely) | Processed by Esbuild, Rollup, or Webpack |
| Production Destination | .dinou/dist3/**/* | .dinou/dist3/assets/* |
| URL Path & Naming | Fixed, exact filename (e.g. /favicon.ico) | Hashed filename (e.g. /assets/hero-a9f2bc14.png) |
Default Cache-Control | public, max-age=0, must-revalidate | public, max-age=31536000, immutable |
| Referencing Syntax | <img src="/images/hero.png" /> | import hero from "./hero.png";<img src={hero} /> |
| Best For | Favicons, robots.txt, sitemaps, verification files, PDFs, OpenGraph cards | Component UI icons, bundled CSS background images, media imported in JS/TSX |
Precedence Rule for public/styles.css
src/, placing a static public/styles.css serves it directly at /styles.css. Whenever any .css or .module.css file is imported in src/, Dinou's compiled stylesheet bundle takes precedence at /styles.css across both dinou dev and dinou build, ignoring root public/styles.css with a warning (rename static files in public/ to e.g. public/custom.css).