diff --git a/.vitepress/config.ts b/.vitepress/config.ts index f0d07b20..4aaf80cf 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -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', + }, ], }, { diff --git a/examples/hono-method-override.md b/examples/hono-method-override.md new file mode 100644 index 00000000..8005c221 --- /dev/null +++ b/examples/hono-method-override.md @@ -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 +
+``` + +## See also + +- [hono-method-override](https://github.com/bingtsingw/hono-method-override)