-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for non-React API endpoints #329
Comments
Please provide description. |
I would create another serverless function and configure routes. It's true that there is no direct support for such use cases. |
I used next.js days ago. I found that they support multiple runtimes on the same platform. edge and runtime. just one const https://github.com/himself65/npm-download-stat/blob/74973f915c65c521c396e726f40be97b9cc926c0/src/app/%5Bpkg%5D/page.tsx#L20C1-L20C31 export const runtime = "edge"; I'm not sure if waku providing createPage with runtime would be a good option |
Full JS environment people are using
|
We are taking a different approach. Waku core is designed completely with web standard, and provides wrappers for each runtime. (And I'm not a big fan of That said, we care DX for supporting different runtimes. Will see. |
I want try something soon, but can't tell what it's going to be like yet. |
@dai-shi I don't expect this to be the most robust solution, but I hacked a little solution together to make custom middleware and non-react endpoints possible via a PR in my fork: campbellman#1 I can clean this up, add tests, and submit an actually PR if it's something that aligns with your goals for the project. Otherwise, consider it a little experiment. Love this project btw :) |
Thanks. It's probably similar to something I have in mind. I will refactor things. Please wait for it. (Lots of bug fixes are required before adding features. Please see "help wanted" issues.) Meanwhile, enjoy experiments. |
I moved a task related to this to #513. |
And, reverted to the original issue. Here's my first question. For the second question, |
Changed the title again. |
Embedding + an Though this might require additional work to prevent polluting the global namespace server-side (
For example, app-root-path broke when I imported it into the same node process as waku. |
I'll add "Use it at your own risks" warning. 😄 |
I recently encountered this non-react API issue. I'm developing a React component that need to fetch First I use custom nodejs + hono. const app = new Hono();
app.get('/api/xxx', c => c.text('xxx')) But I cannot fetch this API in react, I don't know the current server port, so my workaround be like: const env = {
...process.env,
MAIN_PORT: `${port}`,
};
if (isDev) {
const { unstable_honoMiddleware: connectMiddlewareDev } = await import(
"waku/dev"
);
hono.use(
connectMiddlewareDev({
env,
ssr: false,
}),
);
} if (!getEnv("MAIN_PORT")) {
// waku build try to SSR the code
return doc;
}
const port = +(getEnv("MAIN_PORT") as string);
const userDataPath = await fetch(
`http://localhost:${port}/path/userData`,
).then((res) => res.text()); Second, you can see from the example code that Waku still wanna Imaging I'm building a react app, and one of RSCs called database uses a dev database in my local environment. Because of this behavior, I think Not sure how @dai-shi think about this |
Do you mean a server component to fetch an api on the same server?
Even if we disable SSR for |
I found that it's a bug, opening an issue |
We have a low-level solution, "middleware". |
While we wait for #329 (which takes time to design and implement, and we believe most cases are covered by server actions), we can use the low-level middleware api.
I want to extend the Vercel serverless function to support non-react functions like AI stream(text stream), JSON response.
vercel edge function example:
Related discussion: #290
The text was updated successfully, but these errors were encountered: