-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(adapter-netlify)!: migrate to the modern Netlify Functions API #15203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
teemingc
merged 10 commits into
sveltejs:main
from
serhalp:refactor/netlify-functions-v2
Feb 12, 2026
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
35e8762
refactor!: migrate to the modern Netlify Functions API
serhalp 0d14399
there are no unit tests anymore
teemingc 324129f
chore: better changesets
serhalp 312d3bf
fix: exclude special .netlify/ path from generated function
serhalp 3f81780
Apply suggestion from @benmccann
teemingc 600efd1
Apply suggestion from @benmccann
teemingc afa9a10
Merge branch 'main' into refactor/netlify-functions-v2
teemingc 4d06096
add ambient types
teemingc ed8bc9d
bump peer version of kit
teemingc 01184a9
chores
teemingc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| '@sveltejs/adapter-netlify': minor | ||
| --- | ||
|
|
||
| chore!: Migrate to the modern Netlify Functions API | ||
|
|
||
| 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. | ||
|
teemingc marked this conversation as resolved.
Outdated
|
||
|
|
||
| For more details on features this unlocks for your SvelteKit app, see | ||
| https://developers.netlify.com/guides/migrating-to-the-modern-netlify-functions/. | ||
|
|
||
| BREAKING CHANGES: | ||
|
|
||
| - `platform.context` is now the [modern Netlify Functions | ||
| context](https://docs.netlify.com/build/functions/api/#netlify-specific-context-object) | ||
|
serhalp marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 3 additions & 36 deletions
39
packages/adapter-netlify/test/apps/basic/netlify/functions/render.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,6 @@ | ||
| // This is a temporary workaround to be compatible with Netlify's new dev server | ||
| // TODO: remove this once we overhaul the Netlify adapter to use Netlify's new serverless function format https://docs.netlify.com/build/functions/get-started/?data-tab=TypeScript#write-a-function | ||
|
|
||
| import { handler } from '../../.netlify/functions-internal/sveltekit-render.mjs'; | ||
|
|
||
| /** | ||
| * @param {Request} request | ||
| * @param {import('@netlify/functions').HandlerContext} context | ||
| */ | ||
| export default async function (request, context) { | ||
| const [rawUrl, rawQuery] = request.url.split('?'); | ||
| /** @type {import('@netlify/functions').HandlerEvent} */ | ||
| const event = { | ||
| rawUrl, | ||
| rawQuery: rawQuery || '', | ||
| headers: Object.fromEntries(request.headers), | ||
| httpMethod: request.method, | ||
| isBase64Encoded: false, | ||
| path: new URL(request.url).pathname, | ||
| queryStringParameters: Object.fromEntries(new URL(request.url).searchParams), | ||
| body: request.body && (await request.text()), | ||
| multiValueHeaders: {}, | ||
| multiValueQueryStringParameters: null | ||
| }; | ||
| const result = await handler(event, context); | ||
| if (result) { | ||
| return new Response(result.body, { | ||
| status: result.statusCode, | ||
| // @ts-ignore | ||
| headers: result.headers | ||
| }); | ||
| } | ||
|
|
||
| return new Response('Not Found', { status: 404 }); | ||
| } | ||
| export { default } from '../../.netlify/functions-internal/sveltekit-render.mjs'; | ||
|
|
||
| export const config = { | ||
| path: '/*' | ||
| path: '/*', | ||
| preferStatic: true | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.