@hydration-audit/fresh
v0.2.0
Published
Fresh (Deno) adapter for Hydration Tax Brain
Readme
@hydration-audit/fresh
Fresh (Deno) adapter for the Hydration Cost Visibility Platform.
Analyzes hydration costs in Fresh projects by scanning the islands/ directory convention.
Installation
npm install @hydration-audit/freshUsage
With the CLI
# Fresh auto-detected from package.json
npx @hydration-audit/cli analyze ./dist
# Or specify explicitly
npx @hydration-audit/cli analyze --config '{"framework":"fresh"}'Programmatic
import { analyze } from '@hydration-audit/core';
import { FreshAdapter } from '@hydration-audit/fresh';
const report = await analyze({
adapter: new FreshAdapter(),
cwd: '/path/to/fresh-project',
});How It Works
Island Discovery
Fresh uses a strict convention: every file in islands/ is a hydrated component. The adapter scans this directory recursively:
islands/
Counter.tsx → Island "Counter"
SearchBar.tsx → Island "SearchBar"
nested/
Chart.tsx → Island "Chart"Page Detection
The adapter scans routes/ files for imports from islands/ to determine which pages use which islands.
Framework Detection
Fresh uses Preact by default. The adapter checks import statements — if a component imports from "react", it's marked as React; otherwise Preact.
Key Difference from Astro
Fresh islands always hydrate immediately (equivalent to client:load). There are no hydration directives like Astro's client:visible or client:idle. This means the eager-below-fold rule is especially relevant for Fresh projects.
Exported API
| Export | Description |
|---|---|
| FreshAdapter | FrameworkAdapter implementation |
| scanIslands(srcDir) | Scan islands/ directory for components |
| adapter | Pre-instantiated adapter for auto-discovery |
License
MIT
