Can I pass some props to root.tsx in my Qwik application?

22 views Asked by At

I'm using express to run my Qwik app. In entry.express.tsx file we have this line:

const { router, notFound } = createQwikCity({ render, qwikCityPlan, manifest });

And render is imported this way:

import render from "./entry.ssr";

In entry.ssr.tsx file we have this code:

import {
    renderToStream,
    type RenderToStreamOptions,
} from "@builder.io/qwik/server";
import { manifest } from "@qwik-client-manifest";
import Root from "./root";

export default function (opts: RenderToStreamOptions) {
    const props = {
        name: "somebody"
    }
    return renderToStream(<Root {...props} />, {
        manifest,
        ...opts,
        // Use container attributes to set attributes on the html tag.
        containerAttributes: {
            lang: opts.serverData?.locale || "en",
            ...opts.containerAttributes,
        },
    });
}

So, <Root /> is in fact the root component exported in the root.jsx file. So, I decided to pass { name: "somebody" } to the root.tsx file and log it:

export default component$(props => {
    console.log(props)

But it does not print anything.

I need to read something from the disk when my Qwik app gets loaded, and pass it to my app. Is that possible?

0

There are 0 answers