Bird
Raised Fist0
Denoframework~20 mins

Why Fresh is Deno's official web framework - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Fresh Framework Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does Fresh use islands architecture?

Fresh uses an islands architecture for its web pages. What is the main benefit of this approach?

AIt disables JavaScript completely to ensure maximum security.
BIt forces the entire page to reload on every user interaction for simplicity.
CIt allows only small interactive parts of the page to be hydrated, improving performance.
DIt requires server-side rendering for every user click, increasing server load.
Attempts:
2 left
💡 Hint

Think about how hydration affects page speed and user experience.

❓ component_behavior
intermediate
2:00remaining
What happens when you export an async function named 'handler' in Fresh?

In a Fresh route file, you export an async function named handler. What is its role?

AIt defines client-side event handlers for button clicks.
BIt handles HTTP requests for that route, processing and returning responses.
CIt automatically generates static HTML without server interaction.
DIt configures database connections for the app.
Attempts:
2 left
💡 Hint

Consider what server-side code needs to do when a user visits a page.

📝 Syntax
advanced
2:00remaining
Identify the correct way to define a Fresh component with props

Which option correctly defines a Fresh functional component that accepts props?

Deno
import { h } from "preact";

// Choose the correct component definition below:
Aexport default function Greeting(props) { return <h1>Hello, name!</h1>; }
Bexport default function Greeting() { return <h1>Hello, {name}!</h1>; }
Cexport default Greeting = (props) => { <h1>Hello, {props.name}!</h1> }
Dexport default function Greeting(props) { return <h1>Hello, {props.name}!</h1>; }
Attempts:
2 left
💡 Hint

Remember how to access props and return JSX in a function.

❓ state_output
advanced
2:00remaining
What is the output of this Fresh component with useState?

Consider this Fresh component code snippet:

import { useState } from "preact/hooks";

export default function Counter() {
  const [count, setCount] = useState(0);
  setCount(count + 1);
  return 

Count: {count}

; }

What will be displayed when this component renders?

AThe component causes an infinite loop and crashes.
BCount: 1
CCount: 0
DCount: undefined
Attempts:
2 left
💡 Hint

Think about when state updates happen and how rendering works.

🔧 Debug
expert
3:00remaining
Why does this Fresh route fail with a 404 error?

You created a file at routes/about.tsx with this code:

export default function About() {
  return 

About Page

; }

But when you visit /about in the browser, you get a 404 error. What is the most likely cause?

AThe file name or folder structure does not match the route path exactly; check for typos or casing.
BThe file extension should be <code>.jsx</code> instead of <code>.tsx</code> for Fresh routes.
CThe project is missing a <code>fresh.gen.ts</code> file which is required for route recognition.
DThe <code>routes</code> folder is missing a <code>_middleware.ts</code> file to enable routing.
Attempts:
2 left
💡 Hint

Check how Fresh matches URLs to route files.

Practice

(1/5)
1. What is the main reason Fresh is Deno's official web framework?
easy
A. It uses modern Deno features and server-side rendering for speed.
B. It requires heavy client-side JavaScript for interactivity.
C. It is designed only for mobile app development.
D. It depends on third-party Node.js packages.

Solution

  1. Step 1: Understand Fresh's design goals

    Fresh focuses on speed and simplicity by using Deno's modern features and server-side rendering.
  2. Step 2: Compare options with Fresh's characteristics

    Options B, C, and D contradict Fresh's lightweight and server-side approach.
  3. Final Answer:

    It uses modern Deno features and server-side rendering for speed. -> Option A
  4. Quick Check:

    Fresh = modern Deno + server-side rendering [OK]
Hint: Fresh is fast because it uses server-side rendering [OK]
Common Mistakes:
  • Thinking Fresh needs heavy client-side code
  • Confusing Fresh with mobile-only frameworks
  • Assuming Fresh depends on Node.js packages
2. Which of the following is the correct way to create a new Fresh project using Deno?
easy
A. deno run -A https://fresh.deno.dev/init my-app
B. deno create fresh my-app
C. fresh new my-app
D. deno fresh init my-app

Solution

  1. Step 1: Recall Fresh's official project creation command

    Fresh projects are created by running a Deno script from fresh.deno.dev with permissions.
  2. Step 2: Match the command syntax

    deno run -A https://fresh.deno.dev/init my-app matches the official command format: deno run -A https://fresh.deno.dev/init my-app.
  3. Final Answer:

    deno run -A https://fresh.deno.dev/init my-app -> Option A
  4. Quick Check:

    Fresh project init uses deno run -A URL [OK]
Hint: Fresh uses deno run -A with fresh.deno.dev URL [OK]
Common Mistakes:
  • Using 'deno create' which doesn't exist
  • Trying 'fresh new' without installing Fresh CLI
  • Assuming 'deno fresh init' is valid
3. Given this Fresh component code snippet, what will be rendered in the browser?
export default function Home() {
  return (
    <main>
      <h1>Welcome to Fresh</h1>
      <p>Fast and simple web apps</p>
    </main>
  );
}
medium
A. A syntax error preventing rendering
B. An empty page with no content
C. Only the <h1> tag content is shown
D. <main><h1>Welcome to Fresh</h1><p>Fast and simple web apps</p></main>

Solution

  1. Step 1: Understand Fresh component rendering

    Fresh components return JSX-like HTML elements that render as HTML in the browser.
  2. Step 2: Analyze the returned JSX

    The component returns a <main> element containing <h1> and <p> tags with text content.
  3. Final Answer:

    <main><h1>Welcome to Fresh</h1><p>Fast and simple web apps</p></main> -> Option D
  4. Quick Check:

    JSX returns full HTML structure [OK]
Hint: Fresh renders returned JSX as HTML in browser [OK]
Common Mistakes:
  • Expecting no output or empty page
  • Thinking JSX causes syntax errors in Fresh
  • Assuming partial rendering of tags
4. Identify the error in this Fresh route handler code:
export const handler = {
  GET(req) {
    return new Response('Hello from Fresh!');
  }
};
medium
A. The handler should be a default export, not a named export.
B. The GET method should return a JSON object, not a Response.
C. The handler object must use async functions for HTTP methods.
D. The Response constructor is missing a status code.

Solution

  1. Step 1: Review Fresh handler method requirements

    Fresh expects HTTP method handlers like GET to be async functions returning a Response.
  2. Step 2: Check the GET method definition

    The GET method is synchronous here, missing async keyword, which can cause issues.
  3. Final Answer:

    The handler object must use async functions for HTTP methods. -> Option C
  4. Quick Check:

    Fresh handlers = async functions [OK]
Hint: Fresh HTTP handlers must be async functions [OK]
Common Mistakes:
  • Omitting async keyword in handler methods
  • Returning plain strings instead of Response
  • Confusing default and named exports
5. You want to build a Fresh app that loads data from an API on the server and renders it without client-side JavaScript. Which Fresh feature helps achieve this efficiently?
hard
A. Using client-side React components for all UI
B. Server-side rendering with Islands architecture
C. Adding heavy client-side state management libraries
D. Disabling server rendering to speed up load

Solution

  1. Step 1: Understand Fresh's Islands architecture

    Fresh uses Islands architecture to render most UI on the server and hydrate only small interactive parts on the client.
  2. Step 2: Match the requirement to Fresh features

    Server-side rendering with Islands allows loading data on server and minimal client JS, fitting the requirement.
  3. Final Answer:

    Server-side rendering with Islands architecture -> Option B
  4. Quick Check:

    Fresh Islands = server render + minimal client JS [OK]
Hint: Use Islands for server data and minimal client JS [OK]
Common Mistakes:
  • Thinking all UI must be client-side React
  • Adding heavy client-side libraries unnecessarily
  • Disabling server rendering which slows load
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard