Skip to content

@Elysia/html with React for shadcn/ui #417

Answered by ARCADEGC
ARCADEGC asked this question in Q&A
Discussion options

You must be logged in to vote

Improvement is that I created my own html plugin with the decorate function in a different folder that I can import and use as the html plugin. Not sure how well will it scale. Using a group or something then could help i guess.

import { Elysia } from "elysia";

export const htmlPlugin = new Elysia({
    name: "htmlPlugin",
}).decorate(
    "html",
    ({ set }: { set: { headers: { "Content-Type": string } } }) =>
        (set.headers["Content-Type"] = "text/html"),
);

Then I can import it and use it in the same example:

.use(htmlPlugin)
    .post(
        "/post/:id",
        ({ params }) => {
            return renderToString(
                <Button hx-post="/post/1" hx-swap="afterend">

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ARCADEGC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant