Cloudflare Docs
Pages
Visit Pages on GitHub
Set theme to dark (⇧+D)

Deploy a Qwik site

Qwik is an open-source, DOM-centric, resumable web application framework designed for best possible time to interactive by focusing on resumability, server-side rendering of HTML and fine-grained lazy-loading of code.

In this guide, you will create a new Qwik application implemented via Qwik City (Qwik’s meta-framework) and deploy it using Cloudflare Pages.

​​ Creating a new project

Create a new project by running the following command in your terminal:

$ npm create qwik@latest

You will need to provide a directory for your project (this guide will assume you chose ./qwik-app) and select a starter from a provided list. Choose any of the QwikCity available options.

The command will also ask you if you would like to install npm dependencies, choose yes.

Next, add the Qwik cloudflare-pages adaptor with the following commands:

$ cd qwik-app
$ npm run qwik add cloudflare-pages

Note that as part of the cloudflare-pages adaptor installation, a functions/[[path]].ts file will be created. The [[path]] filename indicates that this file will handle requests to all incoming URLs. Refer to Path segments to learn more.

After selecting your server option, change the directory to your project and render your project by running the following command:

$ npm start

​​ Before you continue

All of the framework guides assume you already have a fundamental understanding of Git. If you are new to Git, refer to this summarized Git handbook on how to set up Git on your local machine.

If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub.

Refer to the GitHub documentation and Git documentation for more information.

​​ Create a GitHub repository

Create a new GitHub repository by visiting repo.new. After creating a new repository, prepare and push your local application to GitHub by running the following commands in your terminal:

$ git init
$ git remote add origin https://github.com/<your-gh-username>/<repository-name>
$ git add .
$ git commit -m "Initial commit"
$ git branch -M main
$ git push -u origin main

​​ Deploying with Cloudflare Pages

Deploy your site to Pages by logging in to the Cloudflare dashboard > Account Home > Pages and selecting Create a project. Select the new GitHub repository that you created and, in the Set up builds and deployments section, provide the following information:

Configuration optionValue
Production branchmain
Framework presetQwik
Build commandnpm run build
Build directorydist

After configuring your site, you can begin your first deploy. You should see Cloudflare Pages installing npm, your project dependencies, and building your site before deploying it.

After deploying your site, you will receive a unique subdomain for your project on *.pages.dev. Every time you commit new code to your Qwik site, Cloudflare Pages will automatically rebuild your project and deploy it. You will also get access to preview deployments on new pull requests, to preview how changes look to your site before deploying them to production.

​​ Use bindings in your Qwik application

A binding allows your application to interact with Cloudflare developer products, such as KV, Durable Object, R2, and D1.

In QwikCity, add server-side code via routeLoaders and actions. Then access bindings set for your application via the platform object provided by the framework.

The following code block shows an example of accessing a KV namespace in QwikCity.

src/routes/index.tsx
// ...
export const useGetServerTime = routeLoader$(({ platform }) => {
// the type `KVNamespace` comes from the @cloudflare/workers-types package
const { MY_KV } = (platform as { MY_KV: KVNamespace }));
return {
// ....
}
});

​​ Learn more

By completing this guide, you have successfully deployed your Qwik site to Cloudflare Pages. To get started with other frameworks, refer to the list of Framework guides.