@formadapter/nextjs 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ludicrous
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # `@formadapter/nextjs`
2
+
3
+ Next.js-focused aliases for FormAdapter's native React 19 Server Action
4
+ integration.
5
+
6
+ ```sh
7
+ bun add @formadapter/nextjs
8
+ ```
9
+
10
+ ## Create an action
11
+
12
+ ```ts
13
+ // app/profile/actions.ts
14
+ "use server";
15
+
16
+ import { createNextAction, fieldError } from "@formadapter/nextjs";
17
+
18
+ export const saveProfile = createNextAction(profileSchema, async (profile) => {
19
+ if (await emailAlreadyExists(profile.email)) {
20
+ throw fieldError("email", "That email is already registered");
21
+ }
22
+ return { id: await save(profile) };
23
+ });
24
+ ```
25
+
26
+ ```tsx
27
+ <Profile.Form action={saveProfile} />
28
+ ```
29
+
30
+ The action accepts `(previousState, FormData)` and returns the shared,
31
+ serializable `SubmissionState`. FormAdapter's React runtime wires that contract
32
+ through `useActionState`, shows pending state, and applies server field/form
33
+ errors. Successful action data remains typed through `onResult` and
34
+ `initialSubmissionState`.
35
+
36
+ `createNextAction` is an alias of `createServerAction` from
37
+ `@formadapter/server`. This package also re-exports `createSubmissionHandler`,
38
+ `toServerAction`, `parseFormData`, `formError`, `fieldError`, and
39
+ `FormAdapterServerError` for a Next-focused import path.
40
+
41
+ When the client form uses conditional `hidden` or `requiredWhenVisible`
42
+ configuration, pass the same config as the third argument so the server trust
43
+ boundary enforces identical presentation rules:
44
+
45
+ ```ts
46
+ export const saveProfile = createNextAction(profileSchema, save, {
47
+ config: profileConfig,
48
+ });
49
+ ```
50
+
51
+ The decoder restores nested arrays, booleans, typed options, nullable/optional
52
+ values, and files from the FormAdapter FormData codec before running the
53
+ original schema. Authentication, authorization, and ownership checks still
54
+ belong inside every action; browser inputs and hidden controls are untrusted.
@@ -0,0 +1,2 @@
1
+ import { ContextualCreatedSubmissionHandler, CreateSubmissionHandler, CreatedSubmissionHandler, FormAdapterServerError, ServerAction, SubmissionDataFromHandlerResult, SubmissionHandlerContext, SubmissionOptions, SubmissionValueHandler, createServerAction, createServerAction as createNextAction, createSubmissionHandler, createSubmissionHandlerFactory, fieldError, formError, parseFormData, toServerAction } from "@formadapter/server";
2
+ export { type ContextualCreatedSubmissionHandler, type CreateSubmissionHandler, type CreatedSubmissionHandler, FormAdapterServerError, type ServerAction, type SubmissionDataFromHandlerResult, type SubmissionHandlerContext, type SubmissionOptions, type SubmissionValueHandler, createNextAction, createServerAction, createSubmissionHandler, createSubmissionHandlerFactory, fieldError, formError, parseFormData, toServerAction };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { FormAdapterServerError, createServerAction, createServerAction as createNextAction, createSubmissionHandler, createSubmissionHandlerFactory, fieldError, formError, parseFormData, toServerAction } from "@formadapter/server";
2
+ export { FormAdapterServerError, createNextAction, createServerAction, createSubmissionHandler, createSubmissionHandlerFactory, fieldError, formError, parseFormData, toServerAction };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@formadapter/nextjs",
3
+ "version": "0.0.0",
4
+ "description": "Native Next.js Server Action helpers for FormAdapter.",
5
+ "keywords": [
6
+ "forms",
7
+ "nextjs",
8
+ "react",
9
+ "server-actions",
10
+ "typescript"
11
+ ],
12
+ "homepage": "https://formadapter.com",
13
+ "bugs": {
14
+ "url": "https://github.com/ludicroushq/formadapter/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/ludicroushq/formadapter.git",
19
+ "directory": "packages/nextjs"
20
+ },
21
+ "author": "ludicrous",
22
+ "type": "module",
23
+ "sideEffects": false,
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "main": "./dist/index.js",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
43
+ "scripts": {
44
+ "build": "tsdown",
45
+ "clean": "rm -rf dist tsconfig.tsbuildinfo .turbo",
46
+ "test": "vitest run --config vitest.config.ts",
47
+ "test:coverage": "vitest run --config vitest.config.ts --coverage",
48
+ "typecheck": "tsc --project tsconfig.json --noEmit"
49
+ },
50
+ "dependencies": {
51
+ "@formadapter/server": "^0.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "zod": "^4.4.3"
55
+ },
56
+ "license": "MIT"
57
+ }