Skip to content

Commit

Permalink
slim docs down
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 11, 2022
1 parent ea1f75e commit 6ae9e7a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions documentation/docs/01-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,28 +161,27 @@ The `body` property of the request object will be provided in the case of POST r

#### HTTP Method Overrides

In contrast to `fetch` the only valid methods for a `<form>` are GET and POST. Svelte allows you to override the `<form>` method to workaround this limitation if you need to. By using fetch and `<form>` interchangeably with the same endpoint, your application can continue to work when JavaScript fails or is disabled.

Specify the override method via a query string value, with the key being what's defined in the [`parameter`](#configuration-methodoverride) config option. The original method on the form must be `POST` and cannot be overridden with `GET`. Define which methods can override the `POST` using the [`allowed`](#configuration-methodoverride) config option. Default is an empty array
HTML `<form>` elements only support `GET` and `POST` methods natively. You can allow other methods, like `PUT` and `DELETE`, by specifying them in your [configuration](#configuration-methodoverride) and adding a `_method=VERB` parameter (you can configure the name) to the form's `action`:

```js
// svelte.config.js
export default {
kit: {
methodOverride: {
parameter: '_method',
allowed: ['PUT', 'PATCH', 'DELETE'],
},
allowed: ['PUT', 'PATCH', 'DELETE']
}
}
};
```

```html
<form method="post" action="/todos/{id}?_method=PUT">
<!-- form elements -->
<!-- form elements -->
</form>
```

> Using native `<form>` behaviour ensures your app continues to work when JavaScript fails or is disabled.
### Private modules

A filename that has a segment with a leading underscore, such as `src/routes/foo/_Private.svelte` or `src/routes/bar/_utils/cool-util.js`, is hidden from the router, but can be imported by files that are not.
Expand Down

0 comments on commit 6ae9e7a

Please sign in to comment.