Adapters are responsible for taking the production output from Gatsby and turning it into something your deployment platform understands. They make it easier to build and deploy Gatsby sites on any deployment platform.
Gatsby has different rendering options and features like Deferred Static Generation (DSG) and Server-Side rendering (SSR) require more setup than classic static site generation (SSG). Users can also set HTTP headers or create redirects.
Gatsby passes all the required information during the build to adapters to prepare these outputs for deployment on a specific platform. Here are some of the actions an adapter automatically takes:
- Applies HTTP headers to assets
- Applies redirects and rewrites. The adapter can also create its own redirects or rewrites if necessary, for example to map serverless functions to internal URLs.
- Wraps serverless functions coming from Gatsby with platform-specific code (if necessary). Gatsby will produce Express-like handlers.
- Apply trailing slash behavior and path prefix to URLs
- Possibly uploads assets to CDN
This feature was added in
You can use these official adapters:
To find additional community adapters, search npm for
Can’t find an adapter for your platform? Consider creating an adapter yourself.
adapter option inside
If the adapter accepts custom options, you can set them like this: