Qwik is a modern framework designed for high-performance websites. This guide walks you through deploying Qwik projects to Edgio.
Example
This examples uses a Qwik boilerplate project that you can deploy to Edgio.
Prerequisites
Setup requires:
- An Edgio account. Sign up for free.
- An Edgio property. Learn how to create a property.
- Node.js. View supported versions and installation steps.
- Edgio CLI.
Install the Edgio CLI
If you have not already done so, install the Edgio CLI.
Bash
1npm i -g @edgio/cli@latest
Create your Qwik project
If you don’t have an existing Qwik project, you can create one by running:
Bash
1npm create qwik@latest
Configure Express Middleware
Edgio requires an Express server to run Qwik projects. This can be configured using Qwik’s Node.js middleware.
To add this middleware to your project, run:
Bash
1npm run qwik add express
Follow the instructions provided by the Qwik CLI to add the middleware to your project.
Initializing your Project
Initialize your project for use with Edgio by running the following command in your project’s root directory:
Bash
1edgio init --edgioVersion latest
This will automatically add all of the required dependencies and files to your project, including:
- The
@edgio/core
package - The
@edgio/cli
package - The
@edgio/connectors
package edgio.config.js
- Contains various configuration options for Edgio.routes.js
- A default routes file that sends all requests to the Qwik server. Update this file to add caching or proxy some URLs to a different origin.
Routing
The default
routes.js
file created by edgio init
sends all requests to Qwik server via a fallback route.JavaScript
1// This file was added by edgio init.2// You should commit this file to source control.34const {Router} = require('@edgio/core/router');5const {connectorRoutes} = require('@edgio/connectors');67export default new Router().use(connectorRoutes);
Running Locally
To test your app locally, run:
Bash
1edgio dev
You can do a production build of your app and test it locally using:
Bash
1edgio build && edgio run --production
Setting
--production
ensures your app runs exactly as it will when deployed to the Edgio cloud.Deploy to Edgio
Deploy your app to the Sites by running the following commands in your project’s root directory:
Bash
1edgio deploy
Your initial CDN-as-code deployment will generate system-defined origin configurations along with those defined within your
edgio.config.js
. Learn more about system-defined origins.See Deployments for more information.