github withastro/astro astro@6.0.0-beta.10

Minor Changes

  • #15231 3928b87 Thanks @rururux! - Adds a new optional getRemoteSize() method to the Image Service API.

    Previously, inferRemoteSize() had a fixed implementation that fetched the entire image to determine its dimensions.
    With this new helper function that extends inferRemoteSize(), you can now override or extend how remote image metadata is retrieved.

    This enables use cases such as:

    • Caching: Storing image dimensions in a database or local cache to avoid redundant network requests.
    • Provider APIs: Using a specific image provider's API (like Cloudinary or Vercel) to get dimensions without downloading the file.

    For example, you can add a simple cache layer to your existing image service:

    const cache = new Map();
    
    const myService = {
      ...baseService,
      async getRemoteSize(url, imageConfig) {
        if (cache.has(url)) return cache.get(url);
    
        const result = await baseService.getRemoteSize(url, imageConfig);
        cache.set(url, result);
        return result;
      },
    };

    See the Image Services API reference documentation for more information.

  • #15077 a164c77 Thanks @matthewp! - Updates the Integration API to add setPrerenderer() to the astro:build:start hook, allowing adapters to provide custom prerendering logic.

    The new API accepts either an AstroPrerenderer object directly, or a factory function that receives the default prerenderer:

    'astro:build:start': ({ setPrerenderer }) => {
      setPrerenderer((defaultPrerenderer) => ({
        name: 'my-prerenderer',
        async setup() {
          // Optional: called once before prerendering starts
        },
        async getStaticPaths() {
          // Returns array of { pathname: string, route: RouteData }
          return defaultPrerenderer.getStaticPaths();
        },
        async render(request, { routeData }) {
          // request: Request
          // routeData: RouteData
          // Returns: Response
        },
        async teardown() {
          // Optional: called after all pages are prerendered
        }
      }));
    }

    Also adds the astro:static-paths virtual module, which exports a StaticPaths class for adapters to collect all prerenderable paths from within their target runtime. This is useful when implementing a custom prerenderer that runs in a non-Node environment:

    // In your adapter's request handler (running in target runtime)
    import { App } from 'astro/app';
    import { StaticPaths } from 'astro:static-paths';
    
    export function createApp(manifest) {
      const app = new App(manifest);
    
      return {
        async fetch(request) {
          const { pathname } = new URL(request.url);
    
          // Expose endpoint for prerenderer to get static paths
          if (pathname === '/__astro_static_paths') {
            const staticPaths = new StaticPaths(app);
            const paths = await staticPaths.getAll();
            return new Response(JSON.stringify({ paths }));
          }
    
          // Normal request handling
          return app.render(request);
        },
      };
    }

    See the adapter reference for more details on implementing a custom prerenderer.

  • #15345 840fbf9 Thanks @matthewp! - Adds a new emitClientAsset function to astro/assets/utils for integration authors. This function allows emitting assets that will be moved to the client directory during SSR builds, useful for assets referenced in server-rendered content that need to be available on the client.

    import { emitClientAsset } from 'astro/assets/utils';
    
    // Inside a Vite plugin's transform or load hook
    const handle = emitClientAsset(this, {
      type: 'asset',
      name: 'my-image.png',
      source: imageBuffer,
    });

Patch Changes

  • #15423 c5ea720 Thanks @matthewp! - Improves error message when a dynamic redirect destination does not match any existing route.

    Previously, configuring a redirect like /categories/[category]/categories/[category]/1 in static output mode would fail with a misleading "getStaticPaths required" error. Now, Astro detects this early and provides a clear error explaining that the destination does not match any existing route.

  • #15444 10b0422 Thanks @AhmadYasser1! - Fixes Astro.rewrite returning 404 when rewriting to a URL with non-ASCII characters

    When rewriting to a path containing non-ASCII characters (e.g., /redirected/héllo), the route lookup compared encoded distURL hrefs against decoded pathnames, causing the comparison to always fail and resulting in a 404. This fix compares against the encoded pathname instead.

  • #15419 a18d727 Thanks @ematipico! - Fixes an issue where the add command could accept any arbitrary value, leading the possible command injections. Now add and --add accepts
    values that are only acceptable npmjs.org names.

  • #15345 840fbf9 Thanks @matthewp! - Fixes an issue where .sql files (and other non-asset module types) were incorrectly moved to the client assets folder during SSR builds, causing "no such module" errors at runtime.

    The ssrMoveAssets function now reads the Vite manifest to determine which files are actual client assets (CSS and static assets like images) and only moves those, leaving server-side module files in place.

  • #15422 68770ef Thanks @matthewp! - Upgrade to @astrojs/compiler@3.0.0-beta

  • Updated dependencies [a164c77, a18d727]:

    • @astrojs/internal-helpers@0.8.0-beta.1
    • @astrojs/markdown-remark@7.0.0-beta.6

Don't miss a new astro release

NewReleases is sending notifications on new releases.