Qwik City
While Qwik focuses on Component API, Qwik City contains API to support the component with common server focused features:
- routing: Define your application routes with directory based routing. (Supports both MPA and SPA routing models.)
- pages: Render application pages, the main feature of an application.
- layouts: Define common shared page layouts to be reused across pages.
- loaders: Fetch data on server to be used by the component.
- actions: Provide a way for the component to request server to perform an action.
- endpoints: A way to define data endpoints for your RESTful API, GraphQL API, JSON, XML or revers proxy.
- middleware: A centralized way to perform cross-cutting concerns such as authentication, security, caching, redirects, and logging.
- server$: A simple way to execute logic on server.
- cache: Control caching of your content.
- env variables: API to manage reading environment variables, commonly used for keys, in platform independent way.
- Supports both Server Side Rending (SSR) for fully dynamic sites as well as Static Side Generation (SSG) to be hosted on static web servers and CDNs.
Qwik¹ City²
Qwik¹: Core framework, stable, primitives, component model.
City²: Opinionated file-based router, middleware, endpoints, and data fetching and update.
We call it a meta-framework for Qwik. Qwik City is to Qwik, what Next.js is to React, what Nuxt is to Vue, SvelteKit to Svelte and Analog is to Angular.
Qwik (core) and Qwik City (routing) solve problems at two layers of abstraction. Qwik, focuses component and state management primitives, while Qwik City brings an opinionated and performant way to build sites at scale. We don't want to lock the ecosystem into a single correct way of building sites, in fact we encourage the community to build alternative solutions on top of Qwik.
While Qwik-City is full of useful functionality, thanks to Qwik's resumability and JavaScript streaming, there is no additional cost to end user from Qwik-City. (zero JavaScript);
Use Qwik City to build an e-commerce website, blog site, or any other website that needs routing, layouts, or data retrieval/updates. Qwik City is built on Qwik, and therefore Qwik City sites are resumable and only download the minimal amount of JavaScript with fine-grained lazy loading.
High Level API Overview
This table shows in which file (index.tsx
vs layout.tsx
) should the respective feature be implemented in.
Partytown
Qwik-City also comes pre-integrated with Partytown allowing your to execute your third-party code off the main thread.