Cover Image for [Test] An introduction to Fresh

[Test] An introduction to Fresh

Image for this page

1 Agustus 2022

For JavaScript and TypeScript developers, Fresh is a Deno-based web framework that facilitates the construction of high-quality, efficient, and customized web apps. You can use it to make whatever you think of, including your home page, a blog, or a sizable web application. In essence, Fresh combines a routing architecture and a templating engine to produce pages on the server as needed. For maximum interactivity, Fresh offers an interface for seamlessly rendering some components on the client in addition to this just-in-time rendering on the server. For rendering and templating on both the server and the client, the framework employs Preact (a lightweight React alternative) as a templating engine and JSX.

Advantages of Fresh

Hard-to-miss features are packed with Fresh and readily usable for creating web applications right out of the box. Here are a few of these characteristics:

  • No build step: You directly write the code that is executed on the client and server. Any necessary translation from TypeScript or JSX to regular JavaScript is performed instantly, as needed. This enables deployments to happen incredibly quickly and iteration loops to happen incredibly quickly.
  • Zero runtime overhead: By default, Fresh ships no JavaScript to the browser. Just a static HTML file.
  • No configuration is required: You don’t need to configure anything to begin developing your application with Fresh. Just use their CLI and get started.
  • Fast and tiny (the framework requires no client JS): Client-side rendering is quite expensive because it ships hundreds of kilobytes of client-side JavaScript to users on each request, slowing down the user experience and increasing power consumption on mobile devices. Fresh embraces the true design of server-side rendering and progressive enhancement on the client side. It uses a different model where 0KB of JavaScript is shipped to the client-side by default. Most rendering is done on the server side, and the client-side is only responsible for re-rendering small islands of interactivity.
  • TypeScript out of the box: Unlike Node.js, you don’t have to configure TypeScript separately in Fresh.
  • Routing files using Next Js: Similar to Next Js (A hybrid static & server rendering Javascript framework ), Fresh renders everything to static HTML on the server instead of sending JavaScript code to the browser.
  • Island-based client hydration: The island-based client hydration model works with small portions of your application that need JavaScript to be interactive. For example, on the docs, they have this counter at the bottom, which was hydrated to provide interactivity. Only the JavaScript required to render the counter is sent to the client.

The connection between Deno and Fresh

The original architect of Node Js created Deno, a Javascript runtime, to respond to many of the issues with the original Node. However, the eco-space is currently in a very early stage of development. Deno is a secure typescript runtime built on Google’s V8, which serves as the JavaScript runtime engine. The capabilities of Node Js will be enhanced by features in Deno. Fresh projects can be distributed to any platform, but for the optimal user experience, it is intended to be pushed to an edge runtime as Deno deploy.

Deno deploy supports

  • ES modules compatible with the web: import dependencies just like in a browser, no need for installation.
  • Direct GitHub integration: push to a branch, examine a deployed preview, and merge to release to production.
  • Builds on the Web: use fetch, WebSocket, or URL just like in the browser.

Creating a new project with Fresh

It’s quite simple to get started using Fresh. Fresh projects can be created by using the Fresh project creation tool. It will scaffold a new project with some example files to get you started. The following commands allow you to create a Fresh project.

Fresh Folder Structure

Rekomendasi

cover image for How Racists Ruined Our Anniversary: Going Outdoors While Interracial

How Racists Ruined Our Anniversary: Going Outdoors While Interracial

It was one of those gloriously bright, extremely windy and slightly brisk days that feels like Fall up north, and feels rare and magical in Southwest Florida. As we hustled to the boardwalk leading to the beach, long strands of my curly hair got stuck in my lip gloss, which felt simultaneously annoying and glamorous. I’d had my hair cropped short since 2001, and only grew it out due to COVID; at first, because I wasn’t comfortable going into a salon, and then, to see how far I could go with it. I now have a love-hate relationship with it — lightweight but curly and apt to tangle, a product of the Italian roots I only recently learned existed, and possibly the 3% Afro-Caribbean ancestry, according to one DNA test. I was wearing sunblock on my face, because my fair skin is apt to burn when it’s been shielded from sun exposure chronically, as it has these last two years. My husband never wears sunblock, relying on his ample supply of natural melanin to protect him, passed down from his Nigerian, Cameroonian and Kenyan ancestors

3 Agustus 2022

Next
cover image for What if We Simply Eat Less?

What if We Simply Eat Less?

Cutting just a few calories offers big health benefitsImage: PexelsAfter a weeks-long camping trip through remote desert and mountain areas across the West, I had to tighten my belt a full notch. Literally. I’m in reasonably good shape and, at 5–11, I consistently weigh around 151 pounds, so I was surprised when I stepped on the scales back home and found I’d dropped 10 pounds.Here’s the kicker: ` I felt great.I was in a good mood and my body felt trim and capable of doing just about anything except holding up my pants. And there’s only one explanation: I ate less out there

2 Agustus 2022

Next
scroll to top