Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/cyan-crews-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'astro': major
---

Removes the old `app.render()` signature (Adapter API)

In Astro 4.0, the `app.render()` signature that allowed passing `routeData` and `locals` as optional arguments was deprecated in favor of a single optional `renderOptions` argument.

Astro 6.0 removes this signature entirely. Attempting to pass these separate arguments will now cause an error in your project.

#### What should I do?

Review your `app.render` calls and pass `routeData` and `locals` as properties of an object instead of as multiple independent arguments:

```diff
// my-adapter/entrypoint.ts
-app.render(request, routeData, locals)
+app.render(request, { routeData, locals })
```
20 changes: 20 additions & 0 deletions .changeset/dull-mangos-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'astro': major
---

Removes `prefetch()` `with` option

In Astro 4.8.4, the `with` option of the programmatic `prefetch()` function was deprecated in favor of a more sensible default behavior that no longer required specifying the priority of prefetching for each page.

Astro 6.0 removes this option entirely and it is no longer possible to configure the priority of prefetching by passing the `with` option. Attempting to do so will now cause errors.

By default, Astro's prefetching now uses an automatic approach that will always try to use `<link rel="prefetch>` if supported, or will fall back to `fetch()`.

#### What should I do?

Review your `prefetch()` calls and remove the `with` option if it still exists:

```diff
-prefetch('/about', { with: 'fetch' });
+prefetch('/about');
```
29 changes: 29 additions & 0 deletions .changeset/pretty-forks-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'astro': major
---

Removes the `handleForms` prop for the `<ClientRouter />` component

In Astro 4.0, the `handleForms` prop of the `<ClientRouter />` component was deprecated, as it was no longer necessary to opt in to handling `submit` events for `form` elements. This functionality has been built in by default and the property, if still included in your project, silently had no impact on form submission.

Astro 6.0 removes this prop entirely and it now must be removed to avoid errors in your project.

#### What should I do?

Remove the `handleForms` property from your `<ClientRouter />` component if it exists. It has provided no additional functionality, and so removing it should not change any behavior in your project:

```diff
---
// title="src/pages/index.astro
import { ClientRouter } from "astro:transitions";
---
<html>
<head>
- <ClientRouter handleForms />
+ <ClientRouter />
</head>
<body>
<!-- stuff here -->
</body>
</html>
```
5 changes: 0 additions & 5 deletions packages/astro/components/ClientRouter.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ type Fallback = 'none' | 'animate' | 'swap';
export interface Props {
fallback?: Fallback;
/** @deprecated handleForms is enabled by default in Astro 4.0
*
* Set `data-astro-reload` on your form to opt-out of the default behavior.
*/
handleForms?: boolean;
}
const { fallback = 'animate' } = Astro.props;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/prefetch/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// @ts-nocheck
import { prefetch } from 'astro:prefetch'
document.getElementById('prefetch-manual').addEventListener('click', () => {
prefetch('/prefetch-manual', { with: 'link' })
prefetch('/prefetch-manual')
})
</script>
</body>
Expand Down
2 changes: 0 additions & 2 deletions packages/astro/src/content/data-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export interface DataEntry<TData extends Record<string, unknown> = Record<string
*/
deferredRender?: boolean;
assetImports?: Array<string>;
/** @deprecated */
legacyId?: string;
}

/**
Expand Down
15 changes: 1 addition & 14 deletions packages/astro/src/content/mutable-data-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,7 @@ export default new Map([\n${lines.join(',\n')}]);
entries: () => this.entries(collectionName),
values: () => this.values(collectionName),
keys: () => this.keys(collectionName),
set: ({
id: key,
data,
body,
filePath,
deferredRender,
digest,
rendered,
assetImports,
legacyId,
}) => {
set: ({ id: key, data, body, filePath, deferredRender, digest, rendered, assetImports }) => {
if (!key) {
throw new Error(`ID must be a non-empty string`);
}
Expand Down Expand Up @@ -348,9 +338,6 @@ export default new Map([\n${lines.join(',\n')}]);
if (rendered) {
entry.rendered = rendered;
}
if (legacyId) {
entry.legacyId = legacyId;
}
if (deferredRender) {
entry.deferredRender = deferredRender;
if (filePath) {
Expand Down
21 changes: 10 additions & 11 deletions packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,18 @@ export class App {
return pathname;
}

async render(request: Request, renderOptions?: RenderOptions): Promise<Response> {
let routeData: RouteData | undefined;
let locals: object | undefined;
let clientAddress: string | undefined;
let addCookieHeader: boolean | undefined;
async render(
request: Request,
{
addCookieHeader,
clientAddress = Reflect.get(request, clientAddressSymbol),
locals,
prerenderedErrorPageFetch = fetch,
routeData,
}: RenderOptions = {},
): Promise<Response> {
const url = new URL(request.url);
const redirect = this.#redirectTrailingSlash(url.pathname);
const prerenderedErrorPageFetch = renderOptions?.prerenderedErrorPageFetch ?? fetch;

if (redirect !== url.pathname) {
const status = request.method === 'GET' ? 301 : 308;
Expand All @@ -347,11 +351,6 @@ export class App {
);
}

addCookieHeader = renderOptions?.addCookieHeader;
clientAddress = renderOptions?.clientAddress ?? Reflect.get(request, clientAddressSymbol);
routeData = renderOptions?.routeData;
locals = renderOptions?.locals;

if (routeData) {
this.#logger.debug(
'router',
Expand Down
21 changes: 5 additions & 16 deletions packages/astro/src/core/app/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from 'node:fs';
import type { IncomingMessage, ServerResponse } from 'node:http';
import { Http2ServerResponse } from 'node:http2';
import type { Socket } from 'node:net';
import type { RouteData } from '../../types/public/internal.js';
import { clientAddressSymbol, nodeRequestAbortControllerCleanupSymbol } from '../constants.js';
import { deserializeManifest } from './common.js';
import { createOutgoingHttpHeaders } from './createOutgoingHttpHeaders.js';
Expand Down Expand Up @@ -33,22 +32,12 @@ export class NodeApp extends App {
}
return super.match(req, allowPrerenderedRoutes);
}
render(request: NodeRequest | Request, options?: RenderOptions): Promise<Response>;
/**
* @deprecated Instead of passing `RouteData` and locals individually, pass an object with `routeData` and `locals` properties.
* See https://github.com/withastro/astro/pull/9199 for more information.
*/
render(request: NodeRequest | Request, routeData?: RouteData, locals?: object): Promise<Response>;
render(
req: NodeRequest | Request,
routeDataOrOptions?: RouteData | RenderOptions,
maybeLocals?: object,
) {
if (!(req instanceof Request)) {
req = NodeApp.createRequest(req);

render(request: NodeRequest | Request, options?: RenderOptions): Promise<Response> {
if (!(request instanceof Request)) {
request = NodeApp.createRequest(request);
}
// @ts-expect-error The call would have succeeded against the implementation, but implementation signatures of overloads are not externally visible.
return super.render(req, routeDataOrOptions, maybeLocals);
return super.render(request, options);
}

/**
Expand Down
15 changes: 1 addition & 14 deletions packages/astro/src/prefetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ function initLoadStrategy() {
}

export interface PrefetchOptions {
/**
* How the prefetch should prioritize the URL. (default `'link'`)
* - `'link'`: use `<link rel="prefetch">`.
* - `'fetch'`: use `fetch()`.
*
* @deprecated It is recommended to not use this option, and let prefetch use `'link'` whenever it's supported,
* or otherwise fall back to `'fetch'`. `'link'` works better if the URL doesn't set an appropriate cache header,
* as the browser will continue to cache it as long as it's used subsequently.
*/
with?: 'link' | 'fetch';
/**
* Should prefetch even on data saver mode or slow connection. (default `false`)
*/
Expand Down Expand Up @@ -236,10 +226,7 @@ export function prefetch(url: string, opts?: PrefetchOptions) {
appendSpeculationRules(url, opts?.eagerness ?? 'immediate');
}
// Prefetch with link if supported
else if (
document.createElement('link').relList?.supports?.('prefetch') &&
opts?.with !== 'fetch'
) {
else if (document.createElement('link').relList?.supports?.('prefetch')) {
debug?.(`[astro] Prefetching ${url} with <link rel="prefetch">`);
const link = document.createElement('link');
link.rel = 'prefetch';
Expand Down
Loading