🚧 This documentation is not complete yet as Lagon is in Alpha.
Cloud
Assets

Lagon can host and serve assets such as images, CSS files, and JavaScript files. These assets are static files that are not generated dynamically by your Function.

When deploying a Function, you can specify an assets directory using the --public or -p flag. This directory will be served by Lagon at the root of your Function's URL.

Automatic assets serving

Let's say you have a Function inside an index.ts file, with a favicon and an image:

index.ts
public/
  favicon.ico
  images/
    image.png

To deploy this Function with these asets, you can use the -p or --public flag:

lagon deploy ./index.ts --public public
# Same as
lagon deploy ./index.ts -p public

Your Function is now deployed to example.lagon.dev. You can access the favicon and the image at the following URLs:

  • example.lagon.dev/favicon.ico
  • example.lagon.dev/images/image.png

In your HTML, you can reference these files using relative paths:

<link rel="icon" href="/favicon.ico" />
<!-- ... -->
<img src="/images/image.png" />

Limits

The number and size of assets are limited to prevent abuses. Learn more about the assets limits.