Skip to content

[WIP] Add useAppForm API to Vue#1455

Draft
crutchcorn wants to merge 18 commits intomainfrom
vue-use-app-form
Draft

[WIP] Add useAppForm API to Vue#1455
crutchcorn wants to merge 18 commits intomainfrom
vue-use-app-form

Conversation

@crutchcorn
Copy link
Copy Markdown
Member

@crutchcorn crutchcorn commented Apr 25, 2025

This PR adds the ability to use Form Composition APIs in our Vue adapter.

This PR is blocked on Vue 3.6's release and cannot be released until that version hits Vue's stable channel.

TODOs:

  • Add docs

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 25, 2025

View your CI Pipeline Execution ↗ for commit aba6950

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 41s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-11 00:11:19 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 25, 2025

More templates

@tanstack/angular-form

npm i https://pkg.pr.new/@tanstack/angular-form@1455

@tanstack/form-core

npm i https://pkg.pr.new/@tanstack/form-core@1455

@tanstack/form-devtools

npm i https://pkg.pr.new/@tanstack/form-devtools@1455

@tanstack/lit-form

npm i https://pkg.pr.new/@tanstack/lit-form@1455

@tanstack/preact-form

npm i https://pkg.pr.new/@tanstack/preact-form@1455

@tanstack/react-form

npm i https://pkg.pr.new/@tanstack/react-form@1455

@tanstack/react-form-devtools

npm i https://pkg.pr.new/@tanstack/react-form-devtools@1455

@tanstack/react-form-nextjs

npm i https://pkg.pr.new/@tanstack/react-form-nextjs@1455

@tanstack/react-form-remix

npm i https://pkg.pr.new/@tanstack/react-form-remix@1455

@tanstack/react-form-start

npm i https://pkg.pr.new/@tanstack/react-form-start@1455

@tanstack/solid-form

npm i https://pkg.pr.new/@tanstack/solid-form@1455

@tanstack/solid-form-devtools

npm i https://pkg.pr.new/@tanstack/solid-form-devtools@1455

@tanstack/svelte-form

npm i https://pkg.pr.new/@tanstack/svelte-form@1455

@tanstack/vue-form

npm i https://pkg.pr.new/@tanstack/vue-form@1455

commit: eef8e51

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2025

Codecov Report

❌ Patch coverage is 68.57143% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.93%. Comparing base (6892ed0) to head (eef8e51).
⚠️ Report is 214 commits behind head on main.

Files with missing lines Patch % Lines
packages/vue-form/src/createFormComposition.tsx 68.57% 10 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1455      +/-   ##
==========================================
+ Coverage   90.35%   90.93%   +0.57%     
==========================================
  Files          38       60      +22     
  Lines        1752     2349     +597     
  Branches      444      571     +127     
==========================================
+ Hits         1583     2136     +553     
- Misses        149      191      +42     
- Partials       20       22       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@crutchcorn crutchcorn marked this pull request as draft April 25, 2025 14:20
@daniel100097
Copy link
Copy Markdown

Hi, I was just looking for a way to split a form in Vue (using TanStack Form) into separate fieldset components (using useAppForm).

Have you by any chance already found a way to pass the form context to a fieldset component in Vue? Or maybe a way to work with just a subset of the main form?

Specifically, I was trying to create a reusable fieldset for an address, so I could easily reuse it across different forms.

@crutchcorn
Copy link
Copy Markdown
Member Author

Unfortunately we're blocked by this ATM on Vue's side:

vuejs/core#8553

@daniel100097
Copy link
Copy Markdown

Even though it's not ideal with Vue, it might make sense to use the workaround for now — and once the Vue issue is resolved, we wouldn't need the workaround anymore.

I just tested it again with your StackBlitz example, and as soon as I write <component :is="compMap.one"/> , it seems to work.

    _createVNode($setup["SlotProvider"], null, {
      default: _withCtx(({ compMap }) => [
        (_openBlock(), _createBlock(_resolveDynamicComponent(compMap.one))),
        _cache[0] || (_cache[0] = _createElementVNode("p", null, "Despite it being a valid JS object and such:", -1 /* CACHED */)),
        _createElementVNode("p", null, _toDisplayString(JSON.stringify(compMap, null, 2)), 1 /* TEXT */)
      ]),
      _: 1 /* STABLE */,
      __: [0]
    })

@crutchcorn
Copy link
Copy Markdown
Member Author

No dice; Since we're in v1, introducing an API on our end requires docs, migration patterns, and more. I've considered allowing for <component :is> but don't want to have folks have to recant old code per a suggestion once Vue is updated.

The workaround for now - if you'd like to do that yourself until we launch - is to copy+paste the implementation of useAppForm and such into your codebase - shouldn't require any additional changes upstream.

@mkeyy0
Copy link
Copy Markdown

mkeyy0 commented Nov 20, 2025

@crutchcorn
First of all, thank you, TanStack team, for the great library; it really simplifies form building.

However, Vue is really missing the form composition feature. I know vuejs/core#8553 blocks this, but I agree with @daniel100097 here - I think it makes sense to release it with the current limitation that requires using <component :is /> syntax.

IMO, a limitation on the Vue side shouldn't block this feature, as this workaround is a reality of working with the Vue framework. Once the issue is resolved (or not, cause in vue you have to do the same trick for other situations, like when you use a component in computed, etc), existing code using <component :is /> will continue to work anyway, and users will gain the option to use hook components without it. The TanStack implementation itself won't need to change; it's just the framework-specific usage that will change.

P.S. I found that even Vue Router uses <component :is /> to create a transition, it exposes the Component from the slot, which you have to render with <component :is />. See: https://router.vuejs.org/guide/advanced/transitions#Transitions. Or do you have other concerns that stop you from doing that?

P.P.S. Also, I found that <component :is /> doesn't deal well with TypeScript, so it is also an issue with this approach, so maybe we should push the vue team to ship this faster

@crutchcorn
Copy link
Copy Markdown
Member Author

Great news here y'all:

vuejs/core#8553

Has finally been merged! :D

This means that Vue 3.6 will support our needs here and unblock the PR from moving forward. I'll be prepping this PR for merge leading up to that point

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4916b12-1826-49dd-b517-050cd3862195

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vue-use-app-form

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@mkeyy0
Copy link
Copy Markdown

mkeyy0 commented May 6, 2026

Omg! That's such a great news! Thank you for your amazing work!

@crutchcorn crutchcorn changed the title feat: add useAppForm API to Vue [WIP] Add useAppForm API to Vue May 8, 2026
crutchcorn and others added 4 commits May 8, 2026 12:01
# Conflicts:
#	examples/vue/array/package.json
#	examples/vue/simple/package.json
# Conflicts:
#	examples/vue/array/package.json
#	examples/vue/simple/package.json
#	pnpm-lock.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants