Skip to content

Conversation

@serhalp
Copy link
Contributor

@serhalp serhalp commented Jan 25, 2026

The Netlify adapter now generates "v2" Netlify Functions, which uses modern standards (ESM, Request, Response) instead of the legacy "Lambda-compatible" or "v1" format. Under the hood, this greatly simplifies the adapter code and improves maintainability. See more details in this guide: https://developers.netlify.com/guides/migrating-to-the-modern-netlify-functions/.

Some key changes:

  • The use of Request/Resonse eliminated the need for special header parsing, special multi-value handling header, base64 encoding of binary responses, and more.
  • Configuration of function routing directly in code eliminated the need for _redirects file generation.
  • As a bonus, this ^ lets us remove the limitation that users cannot specify redirects in netlify.toml.

BREAKING CHANGES:


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2026

🦋 Changeset detected

Latest commit: 01184a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-netlify Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot
Copy link

The Netlify adapter now generates "v2" Netlify Functions, which uses modern standards (ESM, Request,
Response) instead of the legacy "Lambda-compatible" or "v1" format. Under the hood, this greatly
simplifies the adapter code and improves maintainability. See more details in this guide:
https://developers.netlify.com/guides/migrating-to-the-modern-netlify-functions/.

Some key changes:
- The use of Request/Resonse eliminated the need for special header parsing, special multi-value
	handling header, base64 encoding of binary responses, and more.
- Configuration of function routing directly in code eliminated the need for `_redirects` file
	generation.
- As a bonus, this removes the limitation that users cannot specify redirects in `netlify.toml`.

BREAKING CHANGES:
- `platform.context` type changed to https://docs.netlify.com/build/functions/api/#netlify-specific-context-object
@teemingc
Copy link
Member

teemingc commented Jan 25, 2026

Thank you, this is really nice! LGTM. Is there anything we can do to get this out of draft? Ideally, we'd release these breaking changes together with the fix for #1604

@serhalp
Copy link
Contributor Author

serhalp commented Jan 25, 2026

@teemingc It's almost there! I just wanted to:

  • do a bit of manual testing
  • polish up the changeset(s)
  • give a think to what we want for excludedPath (here's what we do for edge functions) — I think preferStatic: true means we just need /.netlify/* here.

I should have some time today.

btw I also have a PR stacked on this one that ports to the modern https://docs.netlify.com/build/frameworks/frameworks-api/, as discussed 😁. I'll open that up later too.

@serhalp
Copy link
Contributor Author

serhalp commented Jan 25, 2026

btw if we're doing a major we could do this one too:

// TODO bump peer dep in next adapter major to simplify this

@serhalp serhalp changed the title refactor(adapter-netlify)!: migrate to the modern Netlify Functions API feat(adapter-netlify)!: migrate to the modern Netlify Functions API Jan 25, 2026
@teemingc
Copy link
Member

teemingc commented Feb 5, 2026

Note that we'll probably add an ambient.d.ts that contains the new Context type so that users have access to the Netlify context object through SvelteKit's event.platform.context. See https://github.com/sveltejs/kit/pull/14203/changes There's also the global Netlify object Netlify.context but this helps standardise it among the adapters.

@teemingc
Copy link
Member

teemingc commented Feb 5, 2026

Does preferStatic exist for edge functions? I can't find it in both the Netlify Edge functions config docs nor the @netlify/edge-functions Manifest type.

@serhalp
Copy link
Contributor Author

serhalp commented Feb 6, 2026

Does preferStatic exist for edge functions? I can't find it in both the Netlify Edge functions config docs nor the @netlify/edge-functions Manifest type.

Sorry if I wasn't clear. The todos in my comment are all complete, other than manually testing this!


To actually answer your question though, no, at the moment there is no preferStatic: true for Edge Functions. This was really a note to myself that doesn't make sense without a bunch of context but... basically if you look at this great doc page my colleague recently added, you'll see that Edge Functions are matched before static files. That's why it's important to list all static paths in excludedPath, to ensure these are served right away without compute. On the other hand, Netlify Functions can be opted in to simply letting static files take precedence with preferStatic: true.

@serhalp serhalp marked this pull request as ready for review February 6, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Netlify adapter to match new serverless function expected output

3 participants