Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ export const sidebarsExamples = (): DefaultTheme.SidebarItem[] => [
text: 'Hono Docs Generator',
link: '/examples/hono-docs',
},
{
text: 'Method Override',
link: '/examples/hono-method-override',
},
],
},
{
Expand Down
38 changes: 38 additions & 0 deletions examples/hono-method-override.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Method Override

[hono-method-override](https://github.com/bingtsingw/hono-method-override) is a third-party plugin that allows you to use HTTP verbs such as PUT or DELETE in places where the client (like standard HTML forms) doesn't support them.

You can install it via:

```bash
npm install hono-method-override
```

## Basic Usage

To use it, import the `methodOverride` middleware and apply it to your Hono app:

```ts
import { Hono } from 'hono'
import { methodOverride } from 'hono-method-override'

const app = new Hono()

app.use('*', methodOverride({ app }))

app.delete('/post', (c) => c.text('DELETE /post'))

export default app
```

In your HTML form, you can then override the method by passing a `_method` query parameter (or customizing the configuration based on the plugin's options):

```html
<form method="POST" action="/post?_method=DELETE">
<button type="submit">Delete Post</button>
</form>
```

## See also

- [hono-method-override](https://github.com/bingtsingw/hono-method-override)
Loading