sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.66k stars 1.93k forks source link

Form action and load function bound to component #9527

Open Beiri22 opened 1 year ago

Beiri22 commented 1 year ago

Describe the problem

Maybe i'm just off in my understanding. You can use svelte components to create reusable visual components. But a component itself (that is not a page by itself) cannot have a load function or defined actions, right? Wouldn't it be useful to have fully-functional components?

An example: The upload component. It's the visual component + a load function that allows to show an already uploaded file; plus the action that is required to upload and maybe replace the file.

To my knowledge, with the current state of sveltekit, the handling of data loading and the action to handle the upload has to be implemented in every page using the component.

Describe the proposed solution

Maybe a separate directiory src/components where you can define svelte components including +component.ts or +component.server.ts for actions and loading.

Alternatives considered

If this is already possible with the current system, just give me a hint.

Importance

nice to have

Additional Information

No response

SushiWaUmai commented 1 year ago

This one is kind of important because my code gets very messy after having separating forms from pages.