Skip to content
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

feat: Improve the extensibility of Hono's Context #3402

Open
sor4chi opened this issue Sep 10, 2024 · 1 comment
Open

feat: Improve the extensibility of Hono's Context #3402

sor4chi opened this issue Sep 10, 2024 · 1 comment
Labels
enhancement New feature or request.

Comments

@sor4chi
Copy link
Contributor

sor4chi commented Sep 10, 2024

What is the feature you are proposing?

Currently, Hono's Context is instantiated internally within HonoBase.

By allowing the Context to be injected into HonoBase externally, third-party libraries could freely provide Hono objects with an extended Context.

hono/src/hono-base.ts

Lines 411 to 417 in f9a23a9

const c = new Context(request, {
path,
matchResult,
env,
executionCtx,
notFoundHandler: this.notFoundHandler,
})

Pros

  • Easier to extend
  • Enhances the purity of HonoBase

Cons

  • Potential for unintended usage
  • Could lead to breaking changes

Background

Hono's Context has become bloated over time as new features have been added with each version update.
Since fields included in the Context are not tree-shakable, efforts like #1846 have been made to reduce the weight of the Context.

If we implemented extensible Contexts, we could provide various presets built on top of a minimal Context, allowing users to select only the necessary fields according to their specific use case.

@sor4chi sor4chi added the enhancement New feature or request. label Sep 10, 2024
@sor4chi sor4chi changed the title # feat: Improve the extensibility of Hono's Context feat: Improve the extensibility of Hono's Context Sep 10, 2024
@yusukebe
Copy link
Member

I have some ideas. I'll share them later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants