Astro Content Collection Storage: Split .astro/data-store.json into Chunks
If a large Astro content collection produces an oversized .astro/data-store.json file, enable the experimental collectionStorage flag in Astro 7.1 or later:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { collectionStorage: 'chunked', },});The default is single-file, which stores collection data in .astro/data-store.json. chunked mode splits the data into multiple files under .astro/data-store/, making it useful when a deployment platform limits the size of an individual asset. The feature is experimental and was added in [email protected], so upgrade and test the build before adding the setting to an older Astro project.
Understand what collection storage changes
Astro content collections have two different concerns that are easy to mix up:
| Concern | Symptom | Relevant setting |
|---|---|---|
| Collection data storage | One generated data file is too large for a host or adapter | experimental.collectionStorage |
| Collection loading memory | A build consumes too much memory while reading many entries | Loader or rendering strategy, including deferRender where supported |
| Generated page assets | HTML, JavaScript, or image files exceed a platform limit | Route, asset, or image configuration |
collectionStorage changes how collection data is written; it does not change your content schema, route URLs, or the number of Markdown entries. It is therefore a targeted fix for a generated data-file boundary, not a general optimization for every large-content build.
Astro’s 7.1 release notes also discuss deferRender for large glob collections. Use that option only when the measured problem is memory during collection loading or rendering. Splitting the data store will not automatically make a memory-heavy parser cheap.
Use the default chunk size first
The collection storage reference says Astro creates a new chunk when the current chunk is larger than 20 MB in chunked mode:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { collectionStorage: 'chunked', },});Start with the default when your host does not document a smaller per-file limit. It keeps the configuration simple and lets Astro choose the split point. After a local build, inspect the generated files rather than assuming that one setting fixed the deployment:
pnpm exec astro buildfind .astro/data-store -maxdepth 1 -type f -printdu -h .astro/data-store/*The exact generated files can vary with the content and Astro version. The check is meant to answer two questions: did the flag take effect, and are the resulting files below the limit that caused the deployment failure?
Set an explicit chunkSize for a stricter host
Use the object form when the platform has a known individual-file limit. The value in the official example is one megabyte:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { collectionStorage: { type: 'chunked', chunkSize: 1024 * 1024, }, },});Leave headroom below the platform limit for metadata, compression differences, and future content growth. Do not set the value based only on today’s largest file; the next content import should not put the build back at the boundary.
If your host limit is expressed in megabytes, convert it to bytes and choose a smaller value. Keep the calculation in the config so a future maintainer can see why the number exists. A very small chunk size can create many files and increase deployment overhead, so choose the smallest safe value rather than the smallest possible value.
Upgrade before enabling the flag
The configuration is not a backward-compatible option for every Astro release. Check the installed version and upgrade deliberately:
pnpm why astropnpm up astropnpm exec astro --versionThen read the upgrade notes for the version range you are entering, run type checks, and build in CI. If the project is pinned to Astro 5 or 6, adding collectionStorage to astro.config.mjs is not a substitute for upgrading; an older config parser may ignore or reject an option it does not know.
Do not upgrade only the framework package while leaving an adapter or integration at an incompatible version. Keep the upgrade, lockfile change, and build result together so a deployment failure can be traced to one change set.
Verify the deployment artifact, not only the local build
After astro build succeeds, inspect the artifact that your adapter or hosting platform actually uploads. Confirm that:
.astro/data-store/contains multiple files whenchunkedis enabled.- No individual data-store file exceeds the platform’s documented limit.
- The adapter includes the generated store files in its output.
- A page that reads a content collection works in a preview or staging deployment.
- The build remains reproducible from a clean checkout.
The last two checks matter because a successful local build does not prove that an adapter packages every generated file correctly. If the build succeeds but deployed assets or links still fail, debug that separate path with Astro assets under a subfolder; collectionStorage is not a routing or base-path setting.
To roll back the storage behavior, set collectionStorage: 'single-file' or remove the experimental flag, then rebuild. Keep the rollback available until the production adapter and deployment pipeline have been verified with the chunked artifact.
The practical decision is: use single-file for the default behavior, chunked when an individual generated data file is the limit, and an explicit chunkSize only when the platform requires a smaller boundary. Measure memory problems separately instead of expecting storage splitting to solve them all.
FAQ
What does Astro collectionStorage do?
It controls how content collection data is stored during a build. The default uses .astro/data-store.json; chunked mode writes multiple files under .astro/data-store/.
Which Astro version added collectionStorage?
The experimental collection storage flag was added in [email protected]. Upgrade an older project before using it and test the adapter and deployment artifact.
What is the default Astro collection chunk size?
In chunked mode, Astro creates a new chunk when the current chunk is larger than 20 MB according to the current collection storage reference. Use an explicit chunkSize for a host with a stricter individual-file limit.
Does chunked collection storage reduce Astro build memory?
Not necessarily. It changes how collection data is written, while memory usage can come from loading or rendering many entries. Measure that problem separately and consider the relevant collection loading options.
References:
Astro Docs: Experimental collection storage
Astro 7.1: Full control over pagination URLs and dev servers
Report a typo or broken link, or suggest a related topic.