- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Open
Labels
feature / enhancementNew feature or requestNew feature or requestformsStuff relating to forms and form actionsStuff relating to forms and form actionsneeds-decisionNot sure if we want to do this yet, also design work neededNot sure if we want to do this yet, also design work neededtypes / typescript
Description
Describe the problem
It seems like there isn't much difference between form actions and an endpoint when you still have to get the data from formData().  Most importantly, this is not type safe, and a redundant extra step.
Describe the proposed solution
https://start.solidjs.com/core-concepts/actions
https://qwik.builder.io/docs/action/
Like Qwik and SolidJS, you should be able to just pass the data directly instead of the excess extra step of using a request object and formData, which is not type safe.
export const actions = {
  login: async (data , { cookies, request }) => {
    const { email } = data;  // automatically typesafe as string type
    const user = await db.getUser(email);
    cookies.set('sessionid', await db.createSession(user));
 
    return { success: true };
  },
  register: async (event) => {
    // TODO register the user
  }
} satisfies [Actions](https://kit.svelte.dev/docs/types#public-types-actions);It should also be true for the data and FormData object in use:enhance:
Alternatives considered
Use TRPC to pass typesafe data to endpoints, but type safety should be built-in.
Importance
would make my life easier
Additional Information
No response
Devr-pro, pixelmund, Nuller-G, hanszoons, turbotobias and 9 more
Metadata
Metadata
Assignees
Labels
feature / enhancementNew feature or requestNew feature or requestformsStuff relating to forms and form actionsStuff relating to forms and form actionsneeds-decisionNot sure if we want to do this yet, also design work neededNot sure if we want to do this yet, also design work neededtypes / typescript