Use Enum Values from backend in the Frontend

I'm using this enum in my backend:

export const VideoYouthProtectionEnum = {
Zero: 'zero',
Six: 'six',
Twelve: 'twelve',
Sixteen: 'sixteen',
Eighteen: 'eighteen',
NotSet: 'notSet'
} as const;

export const VideoYouthProtectionEnum = {
Zero: 'zero',
Six: 'six',
Twelve: 'twelve',
Sixteen: 'sixteen',
Eighteen: 'eighteen',
NotSet: 'notSet'
} as const;
I understand I can infer the types of enums with trpc and use those types in the Frontend like this: type YouthProtection = RouterInputs['api']['update']['payload']['youthProtection']. I would like to understand if there is a way to use the inferred enum as a Value in the frontend, something like this: YouthProtection.Zero
1 Reply
thecmdrunner
thecmdrunner16mo ago
why not just VideoYouthProtectionEnum.Zero? (import it in the frontend)
Want results from more Discord servers?
Add your server