9/18 | Validate feature ideas earlier with AI-driven prototypes

What are best AI tools? Take the State of AI survey

Builder.io
Builder.io
Contact sales

9/18 | Validate feature ideas earlier with AI-driven prototypes

What are best AI tools? Take the State of AI survey

Builder.io
Builder.io
< Back to blog

Qwik

Introducing Qwik City Server Functions

February 15, 2023

Written By Manu Mtz.-Almeida

Today we are thrilled to show what the Qwik Core Team has been working on:

  • Data Loaders: reactive low latency data loading in the server.
  • Form Actions: run server code on user interaction

The Server vs. Browser Duality

One of the core ideas of Qwik is to run your app on the server and continue its execution on the browser when the user interacts. While Qwik was designed from the ground up to be a Server-Side Rendered (SSR) and Single-Page Application (SPA) technology, it doesn't distinguish between server and browser, ie, it treats all code equally, all code might run in the server or the browser.

That's where Qwik City enters the scene, a meta framework built on top of the resumability capabilities of Qwik to bring routing and data-fetching patterns. Qwik City is to Qwik, what NextJS is to React, Sveltekit is to Svelte or Solid Start is to Solid.

Data fetching ecosystem

In this great tweet from Theo (CEO of ping.gg), he points out 3 big camps of solutions for the server/client communication problem:

  • Different teams/companies: GraphQL / REST
  • Same team: tRPC / GraphQL
  • Same team using typescript: tRPC / Qwik City

tRPC hits the sweet spot for most web apps! This is exactly the problem that Qwik City server functions solve.

In the context of Qwik City, the problem becomes a little bit more complicated than hitting an HTTP endpoint, reactivity, validation, streaming, avoiding request waterfalls, caching, and the list goes on. That’s why this is a problem that’s worth solving at the meta-framework level!

Introducing Qwik loader$()

Qwik's Data Loader solves the issue of quickly fetching data to be displayed in the HTML. It helps to ensure that the data is available in a timely manner. This helps to improve the user experience and reduce loading times.

Qwik City goes a long way to execute all relevant loaders as soon as possible and in parallel to keep latency as low as possible, in addition, loaders are connected to the reactivity system of Qwik powered by signals, so new data will automatically and efficiently update all parts of the app that depend on it.

Thanks to defer, loaders can return a promise and start streaming HTML before completion, meaning that we can render and send parts of the site before the loader has resolved. This way, loaders that might take a longer time to resolve will not block the whole site.

Data loaders are equivalent to Next's getServerProps(), Remix loaders, SvelteKit’s load function and SolidStart’s createResource function. They are server-only routines that are executed as soon as possible to reduce latency and provide data to the later rendering process.

However, Qwik is able to take these concepts even further and loader$() comes with some advantages!

Zero-effort type safety

Server loaders are just exported functions that can be consumed, imported, and bring all the type information without any extra errors or manual, error-prone typing.

In other solutions, developers are required to manually specify the types, because the loaders and the components are connected through some internal magic that the type system does not understand, for example:

With Qwik, the type information naturally flows because the loaders references are implicitly imported, allowing TS to do its job for you:

Colocation

Loaders can be located anywhere and referenced and imported from any file, bringing with them their types and data efficiently.

Low-level HTTP request access

Loaders are internally implemented as middleware. This means that loaders get full access to the Request and Response, allowing them to take control of the request header, status, and HTTP body.

Even Qwiks streaming SSR is implemented as a middleware, so even a custom error middleware can capture a crash coming from a component.

Introducing Qwik action$()

Form Actions solve the problem of executing code in the server when there is some user interaction such as: submitting a form, signing in, or adding an item to the cart.

First-class <form> support

Actions can be invoked programmatically with JS from the browser, but they work better as a <form> action endpoint.

Thanks to good old forms, actions can be executed even if the JS is disabled.

Built-in validation

Form actions, such as RESTful APIs, receive data from external sources, such as a browser, so validating is an extremely good practice.

However, the developer usually neglects this diligence because the lack of validation is usually not a problem until YouAreUnderAttackt™️.

Qwik City Actions put validation and type safety together to enjoy the benefits and boost security.

By default, actions come with built-in support for Zod, a TypeScript-first schema validation with static type inference.

Show me the code

Wanna see a live app using the new APIs? Give a try to Promptle a game built with Qwik and Form Actions!

You can also see the source code on Github.

The future is bright

We're thrilled to ship these features following all the iterative feedback, and we can't thank the community enough for all the help.

A lot of work has been put into this release as we are honing in v1 for Qwik and Qwik City.

If you have any feedback, we’d love to hear it!

You can find the core team in our discord server or you can tweet out to QwikDev.

Let’s make the web Qwik!

Share

Twitter
LinkedIn
Facebook
Share this blog
Copy icon
Twitter "X" icon
LinkedIn icon
Facebook icon

Visually edit your codebase with AI

Using simple prompts or Figma-like controls.

Try it nowGet a demo

Design to Code Automation

A pragmatic guide for engineering leaders and development teams


Continue Reading
design9 MIN
How to generate (actually good) designs with AI
September 17, 2025
AI9 MIN
7 Levels of Context Engineering for Designers
September 16, 2025
Design to Code8 MIN
Git Branching for Designers
September 11, 2025

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Resources

User Guides

Developer Docs

Forum

Blog

Github

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Get the latest from Builder.io

By submitting, you agree to our Privacy Policy

  • Fusion

  • Publish

  • Product Updates

  • Design to Code

  • Headless CMS

    Multi-Brand CMS

  • Landing Pages

  • Web Apps

  • Prototypes

  • Marketing Sites

  • Headless Commerce

  • Documentation

  • Fusion Docs

  • Publish Docs

  • Blog

  • Webinars

  • Guides

  • Case Studies

  • Community Forum

  • Partners

  • Affiliate Program

  • CMS Integrations

  • CMS Blueprints

  • Glossary

  • Figma to Code Guide

  • Headless CMS Guide

  • Headless Commerce Guide

  • Composable DXP Guide

  • About

  • Careers

  • Contact Sales

Security

Privacy Policy

SaaS Terms

Compliance

Cookie Preferences

YouTube icon
Github icon
Blsky Icon
Twitter "X" icon
LinkedIn icon
Feed Icon
Gartner Cool Vendor 2024