astro/packages/integrations/netlify
Matthew Phillips 19667c45f3
Netlify Edge: forward requests for static assets (#3170)
* Netlify Edge: forward requests for static assets

* Adds a changeset

* Don't run edge tests, yet
2022-04-22 10:03:25 -04:00
..
src Netlify Edge: forward requests for static assets (#3170) 2022-04-22 10:03:25 -04:00
test Netlify Edge: forward requests for static assets (#3170) 2022-04-22 10:03:25 -04:00
.npmignore Ignore test folder in Netlify 2022-04-19 11:45:19 -04:00
CHANGELOG.md [ci] release (#3165) 2022-04-21 12:19:52 -04:00
package.json Netlify Edge: forward requests for static assets (#3170) 2022-04-22 10:03:25 -04:00
README.md Netlify adapter, add --build flag in the readme (#3157) 2022-04-20 12:25:22 -04:00
tsconfig.json Netlify Edge: forward requests for static assets (#3170) 2022-04-22 10:03:25 -04:00

@astrojs/netlify

Deploy your server-side rendered (SSR) Astro app to Netlify.

Use this adapter in your Astro configuration file, alongside a valid deployment URL:

import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';

export default defineConfig({
	adapter: netlify(),
});

After you build your site the netlify/ folder will contain Netlify Functions in the netlify/functions/ folder.

Now you can deploy!

netlify deploy --build

Edge Functions

Netlify has two serverless platforms, Netlify Functions and Netlify Edge Functions. With Edge Functions your code is distributed closer to your users, lowering latency. You can use Edge Functions by changing the import in your astro configuration file:

import { defineConfig } from 'astro/config';
- import netlify from '@astrojs/netlify/functions';
+ import netlify from '@astrojs/netlify/edge-functions';

export default defineConfig({
	adapter: netlify(),
});

Configuration

dist

We build to a netlify directory at the base of your project. To change this, use the dist option:

import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';

export default defineConfig({
  adapter: netlify({
    dist: new URL('./dist/', import.meta.url)
  })
});

And then point to the dist in your netlify.toml:

[functions]
  directory = "dist/functions"