Convert Figma logo to code with AI

denoland logofresh

The next-gen web framework.

12,171
623
12,171
265

Top Related Projects

6,701

The speed of a single-page web application without having to write any JavaScript

29,083

Build Better Websites. Create modern, resilient user experiences with web fundamentals.

124,777

The React Framework

18,419

web development, streamlined

SolidStart, the Solid app framework

54,014

The Intuitive Vue Framework.

Quick Overview

Fresh is a next-generation web framework for Deno, designed to deliver fast, lightweight, and easy-to-use web applications. It emphasizes server-side rendering, islands architecture, and zero runtime overhead, making it an excellent choice for modern web development.

Pros

  • Zero runtime overhead, resulting in fast performance and small bundle sizes
  • Built-in TypeScript support for enhanced developer experience
  • Hot module reloading for rapid development
  • Simple and intuitive API, making it easy to learn and use

Cons

  • Limited ecosystem compared to more established frameworks
  • Tied to the Deno runtime, which may not be suitable for all projects
  • Relatively new, so it may lack some advanced features found in mature frameworks
  • Limited browser support for older versions due to its modern approach

Code Examples

  1. Creating a basic route:
// routes/index.tsx
export default function Home() {
  return <h1>Welcome to Fresh!</h1>;
}
  1. Using server-side data fetching:
// routes/api/data.ts
export const handler = async (_req: Request): Promise<Response> => {
  const data = await fetchSomeData();
  return new Response(JSON.stringify(data), {
    headers: { "Content-Type": "application/json" },
  });
};
  1. Creating an interactive island component:
// islands/Counter.tsx
import { useState } from "preact/hooks";

export default function Counter() {
  const [count, setCount] = useState(0);
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
}

Getting Started

To start a new Fresh project:

  1. Install Deno: https://deno.land/manual/getting_started/installation
  2. Run the following command:
deno run -A -r https://fresh.deno.dev my-project
cd my-project
deno task start

This will create a new Fresh project in the my-project directory and start the development server. You can now open http://localhost:8000 in your browser to see your new Fresh application.

Competitor Comparisons

6,701

The speed of a single-page web application without having to write any JavaScript

Pros of Turbo

  • Mature ecosystem with extensive documentation and community support
  • Seamless integration with Ruby on Rails and other server-side frameworks
  • Progressive enhancement approach, allowing for graceful degradation

Cons of Turbo

  • Steeper learning curve for developers new to the Hotwire stack
  • Limited flexibility compared to more lightweight alternatives
  • Potential performance overhead for complex applications

Code Comparison

Fresh (server-side rendering):

export default function Home() {
  return (
    <div>
      <h1>Welcome to Fresh</h1>
      <p>This is a server-side rendered page.</p>
    </div>
  );
}

Turbo (client-side rendering with Turbo Frames):

<turbo-frame id="home">
  <h1>Welcome to Turbo</h1>
  <p>This content is loaded dynamically.</p>
</turbo-frame>

Fresh focuses on server-side rendering and island architecture, providing a lightweight and performant solution for Deno-based applications. It offers excellent TypeScript support and a simple API.

Turbo, part of the Hotwire stack, excels in creating reactive web applications with minimal JavaScript. It's particularly well-suited for Ruby on Rails projects and offers a smooth transition for traditional server-rendered applications to more dynamic experiences.

Both frameworks aim to improve web application performance and developer experience, but they cater to different ecosystems and development philosophies.

29,083

Build Better Websites. Create modern, resilient user experiences with web fundamentals.

Pros of Remix

  • More mature ecosystem with extensive documentation and community support
  • Built-in data loading and mutation capabilities for efficient server-client communication
  • Supports both client-side and server-side rendering out of the box

Cons of Remix

  • Steeper learning curve due to its more complex architecture
  • Requires additional setup and configuration compared to Fresh's simplicity
  • Larger bundle size, which may impact initial load times

Code Comparison

Remix route component:

export default function Index() {
  const data = useLoaderData();
  return <div>{data.message}</div>;
}

export function loader() {
  return { message: "Hello from Remix!" };
}

Fresh route component:

export default function Home() {
  return <div>Hello from Fresh!</div>;
}

Fresh's approach is simpler and more straightforward, while Remix offers built-in data loading capabilities. Fresh leverages Deno's runtime, providing a more integrated development experience, whereas Remix offers a more flexible but potentially complex setup. Both frameworks aim to improve developer productivity and application performance, but they take different approaches to achieve these goals.

124,777

The React Framework

Pros of Next.js

  • Larger ecosystem and community support
  • More mature and feature-rich framework
  • Extensive documentation and learning resources

Cons of Next.js

  • Heavier bundle size and potentially slower performance
  • More complex setup and configuration
  • Tied to the Node.js ecosystem

Code Comparison

Next.js:

import { useEffect, useState } from 'react'

export default function Home() {
  const [data, setData] = useState(null)
  useEffect(() => {
    fetch('/api/data').then(res => res.json()).then(setData)
  }, [])
  return <div>{data ? JSON.stringify(data) : 'Loading...'}</div>
}

Fresh:

import { Handlers, PageProps } from "$fresh/server.ts";

export const handler: Handlers = {
  async GET(_, ctx) {
    const data = await fetch("https://api.example.com/data").then(res => res.json());
    return ctx.render(data);
  },
};

export default function Home({ data }: PageProps) {
  return <div>{JSON.stringify(data)}</div>;
}

The code comparison showcases Next.js's client-side data fetching approach versus Fresh's server-side rendering with data fetching. Fresh's approach can lead to better initial load performance and SEO, while Next.js offers more flexibility in data fetching strategies.

18,419

web development, streamlined

Pros of Kit

  • More mature ecosystem with a larger community and extensive documentation
  • Supports both server-side rendering (SSR) and static site generation (SSG)
  • Offers a more flexible routing system with dynamic route parameters

Cons of Kit

  • Steeper learning curve due to Svelte-specific syntax and concepts
  • Requires a build step, which can increase complexity in development workflow
  • Less integrated with the runtime environment compared to Fresh's Deno integration

Code Comparison

Kit (routing):

export const load = ({ params }) => {
  return {
    post: {
      title: `Title for ${params.slug}`,
      content: '...'
    }
  };
};

Fresh (routing):

export default function Page({ params }: PageProps) {
  return <div>Hello {params.name}</div>;
}

Both frameworks offer intuitive routing systems, but Kit provides more built-in functionality for data loading and server-side rendering, while Fresh focuses on simplicity and lightweight components.

SolidStart, the Solid app framework

Pros of Solid Start

  • Offers a more comprehensive full-stack framework with built-in routing and data fetching
  • Provides server-side rendering (SSR) out of the box
  • Supports multiple deployment targets, including Vercel, Netlify, and Node.js

Cons of Solid Start

  • Larger bundle size due to more included features
  • Steeper learning curve for developers new to SolidJS ecosystem
  • Less emphasis on runtime performance compared to Fresh's lightweight approach

Code Comparison

Fresh route component:

export default function Home() {
  return <h1>Welcome to Fresh!</h1>;
}

Solid Start route component:

export default function Home() {
  return (
    <main>
      <h1>Welcome to Solid Start!</h1>
    </main>
  );
}

Both frameworks use a similar component-based approach for defining routes, but Solid Start typically includes more boilerplate for full-stack applications. Fresh focuses on simplicity and minimal overhead, while Solid Start provides a more feature-rich environment for building complex web applications.

54,014

The Intuitive Vue Framework.

Pros of Nuxt

  • Mature ecosystem with extensive documentation and community support
  • Built-in server-side rendering (SSR) and static site generation (SSG)
  • Rich plugin system for easy integration of third-party libraries

Cons of Nuxt

  • Larger bundle size and potentially slower initial load times
  • Steeper learning curve, especially for developers new to Vue.js
  • More complex configuration and setup process

Code Comparison

Nuxt route definition:

// pages/index.vue
export default {
  asyncData({ $axios }) {
    return $axios.$get('https://api.example.com/data')
  }
}

Fresh route definition:

// routes/index.tsx
export const handler: Handlers<Data> = {
  async GET(_, ctx) {
    const resp = await fetch('https://api.example.com/data');
    const data = await resp.json();
    return ctx.render(data);
  },
};

Both frameworks offer server-side rendering capabilities, but Fresh takes a more minimalist approach with its file-based routing system. Nuxt provides a more opinionated structure with built-in features like asyncData, while Fresh relies on Deno's standard library for HTTP requests. Fresh's simplicity may appeal to developers looking for a lightweight solution, while Nuxt's extensive features cater to larger, more complex applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Documentation | Getting started | API Reference

fresh

The Fresh logo: a sliced lemon dripping with juice

Fresh is a next generation web framework, built for speed, reliability, and simplicity.

Some stand-out features:

  • 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 configuration necessary.
  • TypeScript support out of the box.
  • File-system routing à la Next.js.

📖 Documentation

The documentation is available on fresh.deno.dev.

🚀 Getting started

Install the latest Deno CLI version.

You can scaffold a new project by running the Fresh init script. To scaffold a project run the following:

deno run -A -r https://fresh.deno.dev

Then navigate to the newly created project folder:

cd deno-fresh-demo

From within your project folder, start the development server using the deno task command:

deno task start

Now open http://localhost:8000 in your browser to view the page. You make changes to the project source code and see them reflected in your browser.

To deploy the project to the live internet, you can use Deno Deploy:

  1. Push your project to GitHub.
  2. Create a Deno Deploy project.
  3. Link the Deno Deploy project to the main.ts file in the root of the created repository.
  4. The project will be deployed to a public $project.deno.dev subdomain.

For a more in-depth getting started guide, visit the Getting Started page in the Fresh docs.

Contributing

We appreciate your help! To contribute, please read our contributing instructions.

Adding your project to the showcase

If you feel that your project would be helpful to other Fresh users, please consider putting your project on the showcase. However, websites that are just for promotional purposes may not be listed.

To take a screenshot, run the following command.

deno task screenshot [url] [your-app-name]

Then add your site to showcase.json, preferably with source code on GitHub, but not required.

Badges

Made with Fresh

[![Made with Fresh](https://fresh.deno.dev/fresh-badge.svg)](https://fresh.deno.dev)
<a href="https://fresh.deno.dev">
  <img
    width="197"
    height="37"
    src="https://fresh.deno.dev/fresh-badge.svg"
    alt="Made with Fresh"
  />
</a>

Made with Fresh(dark)

[![Made with Fresh](https://fresh.deno.dev/fresh-badge-dark.svg)](https://fresh.deno.dev)
<a href="https://fresh.deno.dev">
  <img
    width="197"
    height="37"
    src="https://fresh.deno.dev/fresh-badge-dark.svg"
    alt="Made with Fresh"
  />
</a>

Hashtags

Use the following hashtags in your social media posts that reference Fresh and as Topics in the About section of your GitHub repos that contain Fresh code. It will assure maximum visibility for your posts and code, and promote Fresh development ecosystem visibility.

  • #denofresh
  • #deno

Github repo Topics will not include the hash symbol.