Allow adapters to pass in platform specific context #3426
Labels
adapters - general
Support for functionality general to all adapters
feature request
New feature or request
Describe the problem
As of #3384, hooks and endpoints receive a standard Request object. This simplified and standardised the API for adapters a lot, but also means that no custom context can be passed into the app for the developer to access.
As an example, when using the
adapter-cloudflare
and deploying to Cloudflare pages, you can pass in KV stores and Durable Objects to your functions. With the current Cloudflare adapter, you cannot access the env that is being passed in.With the new
Request
Response
type pattern implemented, it is now not possible to pass it in at all.This would also be relevant to Netlify, Vercel, and any custom adapter for larger teams using something like Azure or AWS.
Describe the proposed solution
The most straight forward way to solve this would be to pass in the request to
app.render
as part of an object, with the adapter environment passed in as anotherThis would be another breaking change for the adapter API, but shouldn't change anything for applications, as the request is already passed into handlers as part of an object
Another generic type should also be exposed to Handler and Hook functions to allow typing for the environment.
Alternatives considered
There are possibilities of using globals, but this could cause issues in most environments.
Importance
would make my life easier
Additional Information
This is my first issue here, but am really impressed with how everything is amazing with svelte kit so far. Absolutely an inspiration <3
Am happy to create a PR for this if the changes make sense.
Hello from Perth Australia!
The text was updated successfully, but these errors were encountered: