Skip to content
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

Develop a Svelte site with pages with dev mode an bindings #11025

Closed
gerhardcit opened this issue Sep 30, 2023 · 3 comments · Fixed by #12863
Closed

Develop a Svelte site with pages with dev mode an bindings #11025

gerhardcit opened this issue Sep 30, 2023 · 3 comments · Fixed by #12863
Assignees
Labels
content:new Request for new/missing content documentation Documentation edits

Comments

@gerhardcit
Copy link

Which Cloudflare product(s) does this pertain to?

Workers

Subject Matter

How to handle bindings when running sveltekit in dev mode

Content Location

The documentation does not describe how to handle bindings when running sveltekit application in dev mode.
Doing this post build is not a great development experience.

See elithrar/svelte-demo-d1#1

Additional information

No response

@gerhardcit gerhardcit added content:new Request for new/missing content documentation Documentation edits labels Sep 30, 2023
@dario-piotrowicz
Copy link
Member

Hi @gerhardcit thanks a bunch for the issue 🙂, I'm very sorry for the late reply 🙇

Anyways it is currently not possible to access bindings in dev mode as clearly indicated by the SvelteKit docs (both for Workers and Pages).

The only possible solution here is to run wrangler pages dev .svelte-kit/cloudflare (you can also open a separate terminal and run vite build to update your app).

We know that this is not ideal and we are currently working on improving the situation (Pages is facing this issue with different frameworks, in which the Platform/Context object is only populated for production builds, we are working on a path forward for all of them).

We've actually noticed your approach in elithrar/svelte-demo-d1#3 and do think that it has potential 🤩 , we'll actually keep it in mind and could potentially suggest something along those lines if we can't find a more proper solution 🙂 (something like that seems like the only possible solution for now, unless the Svelte team will be able to provide some APIs which could allow us to do things more properly, of course if you have idea please let us know).

I think it is too early do document anything at this point as we're still working through all of this and trying to find the best solutions we can provide for our users.

We'll make sure to document everything (for SvelteKit as well for all the other frameworks) as soon as we can 🙂

In the meantime I'll leave it up to @deadlypants1973 whether we should close this issue or keep it open until we've implemented something and are ready to documented things (we're working on it but we don't and an ETA yet) 🙂

@gerhardcit
Copy link
Author

Using the new miniflare bindings works well.

jculvey/svelte-cf-bindings-poc#1

If you can help me getting npx wrangler d1 execute to use the same path as miniflare for the store, that we have a winner.

@dario-piotrowicz
Copy link
Member

dario-piotrowicz commented Nov 23, 2023

@gerhardcit I've replied to your d1 path question in elithrar/svelte-demo-d1#3 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:new Request for new/missing content documentation Documentation edits
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants