Platform context fallbacks
See original GitHub issueDescribe the problem
- When developing with
svelte-kit dev, theevent.platformobject is always empty, with no great way to mock it. - When building using an adapter like Cloudflare Workers,
event.platformis empty for prerendering.
Describe the proposed solution
Ability to provide a platform object in svelte.config.js that is
- Substituted for
event.platformwhenevent.platformis undefined. - Merged with
event.platform, useful for specifying optional/default platform values. - Both?
Alternatives considered
Perhaps allowing a ‘transform’ function that accepts an event may be better, in case platform needs to change based on inputs?
Importance
would make my life easier
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Fallback Context Policy - Anaplan Community
Hi, Today, when I pulled Comparison Report in our Model, I got additional lines in the "Modules Changed" section, which is like.
Read more >How to use Contextual Fallback with Dialogflow to handle ...
In Part 1, I demonstrated how you can use Context in Dialogflow to build a simple Knock Knock joke. In Part 2, I...
Read more >AMAZON.FallbackIntent - Amazon Lex - AWS Documentation
Invoking a fallback intent uses two steps. In the first step the fallback intent is matched based on the input from the user....
Read more >What is Human Fallback | Helpshift
It's a platform that connects messaging, phone, email, self-service, bots, and AI. Conversations can occur within a single messaging thread, so ...
Read more >ConfigReader · Backstage Software Catalog and Developer ...
(constructor)(data, context, fallback, prefix), Constructs a new instance of the ConfigReader class. Methods. Method, Modifiers, Description ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

My proposal would be, having adapters optionally provide an
adapt_devfunction similar toadaptwhere adapter author provides a mocked platform before request is sent for render. Setting up mocked platform should be adapter specific though.I have managed fix this issue when using
adapter-cloudflare-workers. it is a great workaround that served me well so far.in hooks I use:
Every request is intercepted by following code:
In brief
cloudflareAdapterPlatform.ts:devmode if not exits without any actionwrangler.tomlThis logic should be part of adapter and every adapter should fulfil its platform specific requirements. I understand that there is a desire for keeping codebase free from adapter specific logic. However, I don’t see this happening when endpoint events expose adapter specific platform.
It’s not perfect but here’s what I’ve been using for my base repo: https://github.com/tyvdh/test-kit