Fresh: a new full stack web framework for Deno

Rate this content
Bookmark
SlidesGithubProject website
The video introduces Fresh, a full-stack web framework for Deno, with a focus on server-side rendering and just-in-time rendering on the edge. Fresh offers TypeScript support, uses Islands architecture for client interactivity, and requires no configuration to get started. To install Fresh, use the command 'deno run -A -R https://fresh.deno.dev' followed by the project name. Deno is a runtime for JavaScript, TypeScript, and WebAssembly, featuring built-in tools such as a linter, code formatter, and test runner. Fresh supports static files, dynamic routing, data fetching, middleware, custom error pages, and styling options like TWIN for Tailwind CSS. The Islands architecture allows for specific parts of a web page to be interactive, enhancing performance. Data fetching can be handled through handler or hybrid routes. Middleware in Fresh can modify requests or responses, and custom error pages can be defined. Fresh promotes web standards and aligns closely with modern web development practices.

From Author:

Fresh is a web framework based on Deno and Web standards built to run on the edge

This talk has been presented at Node Congress 2023, check out the latest edition of this JavaScript Conference.

FAQ

Fresh is a full-stack web framework that runs on Deno. It is server-side rendered and supports just-in-time rendering on the edge. Fresh provides out-of-the-box TypeScript support, uses an Islands architecture for client interactivity, and requires no configuration to get started.

To install Fresh, run the following command in your terminal: 'deno run -A -R https://fresh.deno.dev' followed by the name of your project. This installation process is typically quick and straightforward.

Deno is a runtime for JavaScript, TypeScript, and WebAssembly that uses the V8 engine. It is designed for the web and can also be used to create command-line interfaces. Deno includes built-in utilities like a linter, code formatter, test runner, and supports both node.js and npm interoperability.

Key features of Fresh include no build step required, server-side rendering, support for static files, dynamic routing, data fetching, middleware, custom error pages, and styling options. It also utilizes the Islands architecture for enhancing client-side interactivity.

Islands architecture in Fresh refers to a design pattern where only specific parts of a web page (islands) are interactive, while the rest remains static. This approach enhances performance by loading JavaScript only for the interactive components, reducing the overall amount of JavaScript delivered to the client.

Fresh allows for styling using TWIN, a server-side rendered implementation of Tailwind CSS. Alternatively, developers can use standard CSS or add a build step for other CSS pre-processors. Fresh aims to support more server-side rendered styling solutions in the future.

In Fresh, data fetching can be handled through handler routes or hybrid routes. Handler routes involve exporting a function that takes a request and context as arguments and returns a response. Hybrid routes combine the functionalities of API handlers and server-side rendering by using functions named after HTTP verbs in the 'handler' object.

Fresh enables developers to define custom error pages, such as a custom 404 page. These pages can access special props related to the error, and for dynamic routes, the 'context.renderNotFound' method can be used to render these custom error pages when a page does not exist.

Fresh adheres to web standards by utilizing features like import maps, fetch API, and more, aligning closely with modern web development practices. Additionally, Deno, which Fresh is built upon, participates in the WinterCG to collaborate on API interoperability for JavaScript runtimes.

Nick Taylor
Nick Taylor
24 min
17 Apr, 2023

Comments

Sign in or register to post your comment.

Video Transcription

1. Introduction

Short description:

Today we're going to talk about FRESH, a full-stack web framework for Deno. I work at Netlify. I'm from Montreal, Quebec, Canada. If you're looking for me online, I'm at NikkieTOnline pretty much everywhere. If you want to know more about me, visit IAmDeveloper.com. I also stream on Twitch and have a YouTube channel.

Hi, everyone. Today we're going to talk about FRESH, a full-stack web framework for Deno. Before we get started, a little bit about me. As mentioned, I work at Netlify. I'm from Montreal, Quebec, Canada. If you're looking for me online, I'm at NikkieTOnline pretty much everywhere. If you want to know a little more about me, you can visit my website at IAmDeveloper.com. I also stream on Twitch, so if that's something you're interested in, you can check out IAmDeveloper.live. I also have a YouTube channel that you can check at YouTube.IAmDeveloper.com. I am also not a big fan of spiders.

2. Introduction to Fresh and Deno

Short description:

Today we're going to cover what Fresh is, discuss web standards, and dig into the features of Fresh. Deno is a runtime for JavaScript, TypeScript, and WebAssembly (Wasm) that uses V8. It has built-in linter, code formatter, test runner, and interoperability with Node.js and npm. Deno follows web standards and is part of the WinterCG, a community group for API interoperability. To install Fresh, use the command 'deno run-A-R https://fresh.deno.dev project-name' and choose options like Tailwind and VS Code integration. Start Fresh with 'deno task start' in the project's root folder.

Alright, so what are we going to cover today? We're going to go over what Fresh is. We're going to discuss web standards, and then we'll dig into the features of Fresh. After that, there'll be a short demo, and then we can move on to questions and comments.

Alright, let's get to it. So, what is Fresh? Well, hold on. First, we need to talk about Deno. So what is Deno? Deno is a runtime for JavaScript, TypeScript and WebAssembly, or Wasm, that uses V8. For the web, it runs on the Edge. You can also use Deno to create command line interfaces, i.e. CLI's. It's got a built-in linter, there's a built-in code formatter, a built-in test runner, there's node.js interoperability via node specifiers, and there's also npm interoperability via npm specifiers and CDNs.

Alright, let's talk web standards. So, Deno uses web standards. For example, import maps, fetch, request, and response. Like the little drawing over there says, just look it up on MDN. Great docs, but also that's pretty much what you'll need to reference most of the time if you're working with fresh. As part of web standards, Deno is a part of the WinterCG. Web Interoperable Runtimes Community Group. It's a space to collaborate on API interoperability for JavaScript runtimes. Feel free to read more about the WinterCG at wintercg.org.

All right, so where were we? Assuming that you have Deno installed, getting fresh installed is pretty quick. You can just run the command that you see on the slide deck here. So that's deno run-A-R and then https://fresh.deno.dev and the name of your project. That was a lot to say. All right. The installation is pretty quick and you have a couple of options. You can choose Tailwind for Styles, go with VS Code integration via the Deno VS Code extension, and that's pretty much it. We'll go more into the styling story a little later in the talk. To start Fresh, we go into the root folder of the project in a shell and run Deno task start. We won't get into it in this talk, but Deno has a built-in task runner that you can configure via a deno.json file.