Skip to content

Allow arbitrary route meta #3397

Open

Description

@naveeng2402

Describe the feature

Expose the route meta in event, so we can do something like mentioned below similar to nuxt middlewares

// server/api/index.ts
defineRouteMeta({
  public: true,
});

export default defineEventHandler((event) => {
  return "Start by editing <code>server/routes/index.ts</code>.";
});
// middleware/auth.ts
export default defineEventHandler((event) => {
  const meta = getRouteMeta(event)
  if (meta.public) return
  
  // auth logic
});

Additional information

  • Would you be willing to help implement this feature?

Activity

  1. added
    pending triage
    on Jun 10, 2025
  2. ssahillppatell commented on Jun 17, 2025

    @ssahillppatell

    defineRouteMeta is not intended for this use case. It's for specifying OpenAPI meta.
    Also, middleware is called before the actual request, so there is no way to get the route metadata in the middleware.

    We can have an arbitrary meta object in route rules. But that would probably be a deviation from web standards.

  3. naveeng2402 commented on Jul 7, 2025

    @naveeng2402
    Author

    h3js/h3#1118

    I opened this issue requesting something similar to this

  4. added
    enhancement
    and removed
    pending triage
    on Sep 2, 2026
  5. added and removed on Oct 17, 2026
  6. added
    openapi
    and removed
    enhancement
    on Nov 10, 2026
  7. added theissue type on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    openapi

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions