Back to articles
Fresh Framework Has a Free API — Heres How to Build Islands-Based Apps on Deno

Fresh Framework Has a Free API — Heres How to Build Islands-Based Apps on Deno

via Dev.to WebdevAlex Spinov

Fresh is a next-gen web framework for Deno — zero JS shipped by default, islands architecture for interactivity, and instant deployments on Deno Deploy. Why Fresh? Zero JS by default : Pages render as pure HTML Islands architecture : Only interactive components ship JS No build step : Write code, deploy instantly Deno native : TypeScript, permissions, Web APIs built-in Preact : Lightweight 3KB runtime for islands Quick Setup deno run -A https://fresh.deno.dev my-app cd my-app && deno task start File-Based Routing routes/ index.tsx -> / about.tsx -> /about posts/ index.tsx -> /posts [id].tsx -> /posts/:id api/ posts.ts -> /api/posts Route with Data Loading // routes/posts/[id].tsx import { Handlers , PageProps } from ' $fresh/server.ts ' ; export const handler : Handlers = { async GET ( _req , ctx ) { const post = await db . post . findUnique ({ where : { id : ctx . params . id } }); if ( ! post ) return ctx . renderNotFound (); return ctx . render ( post ); }, }; export default functio

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles