Replies: 10 comments 27 replies
-
|
I'm not convinced we should couple ourselves to a specific framework. I assume the difficulty is we have to control this app isn't it? Hence why |
Beta Was this translation helpful? Give feedback.
-
|
On the similar topic of being able to support other types of web/api servers, i built a wrapper to be able to expose an Effect HttpApi using a single https://github.com/withstudiocms/studiocms/tree/main/packages/effectify#effectifyastrohttapi Would be cool to be able to do the reverse of what i'm doing and easily enable Effect's handlers for Astro 🤔 |
Beta Was this translation helpful? Give feedback.
-
|
Could you expand a bit on the user pain points this is aiming to solve? I’m not sure I understand the advantages and locking us in to a specific framework (Hono) feels risky a bit like saying “All Astro apps are Express apps now” would feel risky. |
Beta Was this translation helpful? Give feedback.
-
|
This looks promising. My only question is how it would work alongside the current custom Would |
Beta Was this translation helpful? Give feedback.
-
|
I still don't think tying ourselves to Hono is a good goal. I think basing ourselves on web standards is better and still allows us to support Hono easily. One simple example: // src/app.ts
import { astro, type AppExport } from 'astro/app';
export default {
async fetch(request) {
return astro(request)
}
} satisfies AppExport;An example with Hono: // src/app.ts
import type { AppExport } from 'astro/app';
import { astro } from 'astro/app/hono';
import { Hono } from 'hono'
const app = new Hono().use('*', astro());
export default {
fetch: app.fetch
} satisfies AppExport;In this example, the hono export is very simple: export const astro = (c: { req: { raw: Request } }) => web(c.req.raw)
// alternatively, we could support several shapes and normalizeAnother hono example: // src/app.ts
import { astro } from 'astro/app/hono';
import { Hono } from 'hono'
const app = new Hono().use('*', astro());
export default app;All this to say, I think I would replace the Hono goal by "Use a standard fetch based API" |
Beta Was this translation helpful? Give feedback.
-
|
What worries me about adding hono at the core of SSR is that we delegate important stuff to a third party library, which means that we can't:
If we can make this opt-in, then yes, I think I would vote for it. |
Beta Was this translation helpful? Give feedback.
-
|
Sorry but there's another goal I'd like to discuss, I didn't see it:
I think extracting to packages makes sense in the long run but maybe not short term. Not sure how to phrase this as a goal but I would like is:
Wdyt? |
Beta Was this translation helpful? Give feedback.
-
|
I'm in favor of moving to Stage 2 now 👍 |
Beta Was this translation helpful? Give feedback.
-
|
Moved to stage 2: #1342 |
Beta Was this translation helpful? Give feedback.
-
|
Will we be able to use other languages for example golang, rust etc? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
This proposal introduces optional
src/app.tssupport as Astro's request entrypoint, giving users full control over the request pipeline using a standard fetch-based API. Astro's rendering and features are composed within this entrypoint. A Hono app can also be exported directly since it shares the same{ fetch }shape, and Hono middleware support is provided as an add-on.Background & Motivation
Today, Astro controls the entire request pipeline internally. Users can hook into it with middleware, but they can't control when things run relative to each other or relative to Astro itself. In practice this means:
src/app.tsgives users an explicit entrypoint where they control the full request lifecycle. Astro features like Actions or redirects can be extracted into standalone packages that users compose themselves.Goals
src/app.tsas a first-class request entrypoint.fetch-based API as the contract, allowing users to control the request pipeline with plainRequest/Responseobjects. Since a Hono app exposes the same{ fetch }shape, exporting a Hono app works naturally.astro/hono) for users who want to use Astro features within a Hono middleware chain.src/app.tsis not present.astro/rewritesfor example)src/app.ts.Non-Goals
src/app.tsidea discussed here.Example
Astro features can also be composed individually. The exact API is still being designed, but conceptually it would look something like this (pseudo-code):
Users who prefer Hono can export a Hono app directly and use Astro as Hono middleware via the add-on:
With this model:
src/app.tsis optional.Open questions
src/app.ts? Options include a mutable state object (likeAstroRequestabove), storing state on the request object, or something else.src/app.tsinteract with platform-specific entrypoints like Cloudflare'sworker.ts?Beta Was this translation helpful? Give feedback.
All reactions