A new "Fresh" web framework is out 🍋
Tags: webdev, deno, node, javascript
Published: 2022-08-02 08:53:36

Well, it's the time of the week again, a new fresh web framework has been released and I know exactly what are you thinking
![I can't do this anymore](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tblg6poj4w09ljv4j8f8.jpg)

### What is Fresh?
It's a full-stack framework for server-side rendering, similar to Ruby on rails or Lavarel but you write your app on TypeScript, because it's built on top of Dino, so you get first-class Typescript support out of the box.
In addition, you can build and deploy your app without a build step.

Features according to it's documentation

🍋 - Just-in-time rendering on the edge.
🍋 - Island based client hydration for maximum interactivity.
🍋 - Zero runtime overhead: no JS is shipped to the client by default.
🍋 - No build step.
🍋 - No configuration necessary.
🍋 - TypeScript support out of the box.



![Fresh Deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ftqyixgzq4s47f6pzw7c.png)
 
Fresh can be deployed to the edge instantly with Deno deploy.
One drawback is that Deno has a much small ecosystem than when compared to Node.js and not all NPM packages are compatible.

![nodejs vs Deno](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eqaeu8c5o5ocwfeu9t1.png)

The most interesting thing about fresh is that it's based on the island's architecture which is also known as "Partial Hydration".
The idea is that you build a website using a JavaScript framework, in this case, Fresh used Preact for the UI, but instead of sending JavaScript to the browser, you render everything static HTML on the server, which means by default the only thing the end-user gets is a static HTML, which is faster to the browser to load and render.


![islands architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93tdjth5g0v0whf7aetz.png)
 

But you will think that a website will need more interactivity than static HTML and that's where islands come in.
When a website needs more interactivity than static HTML, it can opt into JavaScript on individual components, the way that works in Fresh is that any component kept in the islands directory, will also ship JavaScript to the browser, and all other components will be rendered as static HTML, but one drawback to being aware of is that every page is server-side rendering, not like next.js where the client-side router takes over after the initial page load then renders everything else client-side.

![Vs Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4u9rnjm430qgu9odtac9.png)
 

It can be harder for libraries to have authentication because you will have to move your authentication logic to the server, preserving state from one route to the next can get tricky.

Another cool thing worth mentioning is that it uses "remix" style form submissions, when submitting a regular HTML form, you can write TypeScript code that will handle that form submission directly in the component file for that page.

![Form Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtc3s9u2vfkx4juzijhg.png)
 
So, let's go and get a new "Fresh" start 🍋.

### Resources
- [Islands Architecture by Jason Miller](https://jasonformat.com/islands-architecture/)
- [Islands Architecture by patterns.dev](https://www.patterns.dev/posts/islands-architecture/)
- [Fresh Deno](https://fresh.deno.dev/)
- [Deno Deploy](https://deno.com/deploy)