Adapters
Introduction
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 differentrendering 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 setHTTP headers or createredirects.
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 produceExpress-like handlers.
- Apply trailing slash behavior and path prefix to URLs
- Possibly uploads assets to CDN
This feature was added ingatsby@5.12.0.
Finding adapters
You can use these official adapters:
To find additional community adapters,search npm forgatsby-adapter.
Can’t find an adapter for your platform? Considercreating an adapter yourself.
Using adapters
Use theadapter option insidegatsby-config:
If the adapter accepts custom options, you can set them like this: