You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, amazing framework! It's my favorite by far! ❤️
I would like to be able to add custom properties or metadata to a server function, similar to the existing url property.
My main use case is assigning a short, stable, unique identifier to each server function. I currently use .url for debugging and as a query key, but the generated URL can be quite long and isn't ideal for these purposes.
Then the custom ID/properties could be accessed from the server function object:
findAddress.id
This would be useful for:
Debugging and logging server functions
Using short, stable identifiers as query keys
Tracing server function calls
Attaching application-specific metadata
Avoiding reliance on the generated .url as an identifier
The generated .url is still useful for routing/internal purposes, but having a dedicated custom identifier would make server functions much easier to identify and work with in application code.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hello, amazing framework! It's my favorite by far! ❤️
I would like to be able to add custom properties or metadata to a server function, similar to the existing url property.
My main use case is assigning a short, stable, unique identifier to each server function. I currently use .url for debugging and as a query key, but the generated URL can be quite long and isn't ideal for these purposes.
Something like this would be very useful:
export const findAddress = createServerFn({
metadata: (context: { url: string }) => ({
id: "MY_FN_" + shortHash(context.url),
}),
})
.validator(getInputSchema())
.handler(() => {})
Or, if a simpler static API is preferred:
export const findAddress = createServerFn({
id: "FIND_ADDRESS",
})
.validator(getInputSchema())
.handler(() => {})
Then the custom ID/properties could be accessed from the server function object:
findAddress.id
This would be useful for:
Debugging and logging server functions
Using short, stable identifiers as query keys
Tracing server function calls
Attaching application-specific metadata
Avoiding reliance on the generated .url as an identifier
The generated .url is still useful for routing/internal purposes, but having a dedicated custom identifier would make server functions much easier to identify and work with in application code.
Thanks for the amazing work on the framework!
All reactions