Next.js Discord

Discord Forum

Best way to handle theming in my layout?

Unanswered
Atlantic salmon posted this in #help-forum
Open in Discord
Atlantic salmonOP
I'm writing a website for hosting competitions. Both users and competitions can have their own themes, and the site uses the following rules to figure out which one to use:

- /comp/[cid]: use the comp theme
- /user/[uid]: use uid's user theme
- /...: anywhere else, use the currently authenticated user's theme

To do this, I've got a really complicated middleware that sets a header based on the URL, and then my main layout makes a database call to fetch the theme depending on the value of the header. This is not only really ugly, but also not very performant.

What would be a better approach to this? I'm using Radix UI's theming if that makes any difference/

3 Replies

i'm curious if you found a better and more performant solution
Atlantic salmonOP
I have not, that's why I'm here...
yea well now i will get notifications : D