Astro 7.1 Delivers Granular Control: CSP, Pagination, Dev Server, and Content Collections

Astro · 14 Jul 2026 · 2 min read

#astro

Astro 7.1 is here, and it's all about giving developers more control. This minor release packs significant enhancements to Content Security Policy (CSP) support, pagination, the development server, and content collections. These updates aim to improve security, flexibility, and developer experience without breaking existing workflows.

Key changes in Astro 7.1:

  • CSP support: Astro now allows you to define a Content-Security-Policy header directly in your astro.config.mjs via the server.csp option. You can specify policies like default-src: 'self' and even use script-src: 'nonce-{nonce}' for inline scripts. This is critical for preventing XSS attacks.
  • Pagination params in getStaticPaths: The paginate() function now provides params in the page object, making it easier to access dynamic route parameters like slug within paginated collections. This simplifies building paginated documentation or blog archives.
  • Dev server improvements: The development server now supports HMR for .astro files when using the --host flag, and the startup time has been reduced for large projects. Additionally, the astro dev command now respects the server.headers config for custom headers.
  • Content collections: The defineCollection() function now accepts a type: 'data' option, allowing you to define collections for data files (JSON, YAML) alongside content files. This unifies the handling of structured data like team members or API endpoints.
  • New injectScript option: In Astro.request, you can now inject scripts into the head element using Astro.request.injectScript, useful for conditionally loading third-party scripts.
  • Deprecation of Astro.fetchContent: This older API is deprecated in favor of Astro.glob; migration warnings guide developers to the new syntax.

For developers, Astro 7.1 reduces boilerplate and enhances security. The CSP support alone is a major win for production sites, while pagination and content collections improvements streamline common patterns. The dev server enhancements mean faster iteration cycles.

Source: https://feat/blog/astro-710/

Related

auto-curated · source linked above ← all news