Skip to content
Merged
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
13 changes: 10 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
node-version: ['20.x', '22.x', '24.x']
react-version: ['18', '19']
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: '22.x'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
Expand All @@ -27,5 +31,8 @@ jobs:
- name: Build
run: npm run build

- name: Install React ${{ matrix.react-version }}
run: npm install --no-save react@${{ matrix.react-version }} react-dom@${{ matrix.react-version }}

- name: Test
run: npm test
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
Expand Down
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ npm install @formspark/use-formspark
yarn add @formspark/use-formspark
```

Requires React 18 or 19 and Node.js 18 or newer.

## Usage

```tsx
Expand All @@ -52,11 +54,11 @@ const ContactForm = () => {
};
```

**Note:** don't confuse the form's action URL (e.g. `https://submit-form.com/capybara`) with the form ID (e.g. `capybara`) — this package only uses the latter.
**Note:** don't confuse the form's action URL (e.g. `https://submit-form.com/capybara`) with the form ID (e.g. `capybara`). This package only uses the latter.

## Error handling

`submit` throws a `FormsparkError` when the server responds with a non-2xx status. The error carries the HTTP status and parsed response body.
`submit` throws a `FormsparkError` when the server responds with a non-2xx status. The error carries the HTTP status and the response body, parsed as JSON when possible and kept as raw text otherwise.

```ts
import { useFormspark, FormsparkError } from "@formspark/use-formspark";
Expand Down
Loading