Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: VueJS + NuxtJS support (#199) #293

Merged
merged 110 commits into from
Apr 24, 2024
Merged

Conversation

markflorkowski
Copy link
Collaborator

Add support for NuxtJS and VueJS

  • Create builder function for Nuxt that will scaffold API route handler
  • Adjust types to comply with NuxtJS type system in case of API Routes
  • Expose proper Request object in middleware
  • Create package for VueJS support
  • Custom hooks composables for VueJS
  • Button
  • Dropzone
  • Upload progress indicator in default components

Update:

Vue package with UploadButton is added. Currently, it has external dependency on VueUse and it's useFetch. Ideally, it should be replaced with something more lightweight

Since I've used defineComponent function to create UploadButton component, I had to make single top-level prop that can be passed in component config
image

So everything else can be passed into config prop object

Example of usage in SFC:

image

Typesafety and autocomplete works as expected
image
image

Correct types in middleware
image

Issues present so far that has to be fixed:

  • Import from @uploadthing/vue is not working. import from @uploadthing/vue/index works but first option is more preferable
  • Can't make TailwindCSS work in NuxtJS example for some reason. It does not generate classes
  • Both UploadButton and UploadDropzone require ClientOnly to work properly. Not sure how much of an issue it is though

Example from FE

Monosnap screencast 2023-07-06 13-26-01

Co-authored-by: Vladislav Zimnikov <[email protected]>
@vercel
Copy link

vercel bot commented Aug 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-uploadthing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 3:59pm

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

A new canary is available for testing. You can install this latest build in your project with:

@github-actions github-actions bot removed the release canary Trigger a canary release to npm label Aug 29, 2023
@markflorkowski
Copy link
Collaborator Author

@Mr0Bread -- created a branch for you, and kicked off a canary build.

@Mr0Bread
Copy link
Contributor

Cool, thanks

@markflorkowski
Copy link
Collaborator Author

@Mr0Bread It looks like it didn't actually publish the vue package. I think you need to add this to the package.json:

"publishConfig": {
    "access": "public"
  },

cc @juliusmarminge

@juliusmarminge
Copy link
Collaborator

So we actually need to change the workflow abit to make sure it's versioned properly:

- name: Authenticate to npm and publish

https://github.com/pingdotgg/uploadthing/blob/main/.github/canary-version.js

Maybe we should change it so it loops over the entire packages folder (except config)

@changeset-bot
Copy link

changeset-bot bot commented Aug 29, 2023

🦋 Changeset detected

Latest commit: 6d0ea09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
uploadthing Minor
@uploadthing/dropzone Minor
@uploadthing/shared Minor
@uploadthing/nuxt Minor
@uploadthing/vue Minor
@uploadthing/react Patch
@uploadthing/solid Patch
@uploadthing/svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Mr0Bread
Copy link
Contributor

@markflorkowski This branch is now part of this repo, not my fork. I'm not sure I'll be able to push into this branch

@markflorkowski
Copy link
Collaborator Author

I'm not sure I'll be able to push into this branch

If not, fork and open PRs against this branch @Mr0Bread

@github-actions
Copy link
Contributor

A new canary is available for testing. You can install this latest build in your project with:

pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add [email protected]
pnpm add @uploadthing/[email protected]

@github-actions github-actions bot removed the release canary Trigger a canary release to npm label Aug 30, 2023
Comment on lines 198 to 202
<ClientOnly fallback-tag="div" fallback="Loading...">
<Uploader :config="{ endpoint: 'videoAndImage', onClientUploadComplete={()
=> { alert("Upload Completed"); }} onUploadError={(error: Error) => { //
Do something with the error. alert(`ERROR! ${error.message}`); }} }" />
</ClientOnly>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this have to be in a client-only block? is it not possible to SSR this and have the file config on first paint?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one have to be fixed. ClientOnly is no longer needed

Co-authored-by: Vladislav Zimnikov <[email protected]>
@t3dotgg t3dotgg mentioned this pull request Sep 12, 2023
@t3dotgg t3dotgg changed the base branch from main to community September 12, 2023 04:21
Copy link
Member

@t3dotgg t3dotgg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work on the dropzone in particular, that didn't look fun to do

@markflorkowski markflorkowski merged commit 09870e4 into main Apr 24, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants