Deploy Frontity on Layer0
Last updated
Was this helpful?
Last updated
Was this helpful?
is an all-in-one platform to develop, deploy, preview, experiment on, monitor, and run your headless frontend. It is focused on large, dynamic sites and best-in-class performance through EdgeJS (a JavaScript-based Content Delivery Network), predictive prefetching, and performance monitoring.
Layer0's EdgeJS enables powerful and precise control of Edge based and that can improve the performance for Frontity sites.
For the full details on deploying Frontity on Layer0 refer to the in the developer documentation.
First start by installing the ,
Run the init
command in the directory of your Frontity project:
This will automatically configure your app for deployment on Layer0.
You can simulate your app running on Layer0 using the dev
command:
In particular, the --cache
option will emulate Edge caching rules locally so that you can test easily test edge behavior during development without having to do a deploy to the cloud:
Once you have installed the CLI and created an account, you should login from the terminal by running the login
command:
Once you have an account and have logged in to the CLI, you can deploy to the Layer0 by running the following in the root folder of your project:
Layer0 improves the performance of your site by bundling an integrated server worker that will predictively prefetch cached pages from the edge. To add the Layer0 service worker to your app, call the install
function from @layer0/prefetch/window
in a useEffect
hook when the app first loads. For example, you can alter the Header component in your theme as follows:
To prefetch data into the browser cache using the service worker, use the Prefetch component from @layer0/react. This component prefetches a specific URL from the Layer0 edge when it becomes visible in the viewport. You typically wrap it around links. For example:
Deploying a Frontity app requires an account on Layer0. .