0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/netlify
github-actions[bot] a74cf98002
[ci] release (#3509)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-02 15:31:44 -04:00
..
src fix: alias astro to @types/astro (#3503) 2022-06-02 12:54:35 -05:00
test Update out directories for Netlify Functions (#3381) 2022-05-16 14:44:21 -04:00
.npmignore Ignore test folder in Netlify 2022-04-19 11:45:19 -04:00
CHANGELOG.md [ci] release (#3509) 2022-06-02 15:31:44 -04:00
package.json [ci] release (#3509) 2022-06-02 15:31:44 -04:00
README.md Update out directories for Netlify Functions (#3381) 2022-05-16 14:44:21 -04:00
tsconfig.json [ci] format 2022-04-22 14:04:54 +00: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 dist 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"