Major Changes
-
#866
d69dd6e
Thanks @juliusmarminge! - refactor: reduce bundle sizeWe've continued our efforts to reduce the bundle size of the client side javascript. In a previous minor release, we reduced the bundle size by 70%, from 120kB to 40kB. This release continues on that work with a further reduction of 35% down to just over 25kB client side
javascript shipped to the browser from theuploadthing/client
package. -
#866
d69dd6e
Thanks @juliusmarminge! - feat!: change signature ofgenUploader
to return an object with 2 functions,uploadFiles
andcreateUpload
createUpload
can be used to create a resumable upload which you can pause and resume as you wish.
See example: https://github.com/pingdotgg/uploadthing/blob/v7/examples/backend-adapters/client-vanilla/src/resumable-upload.ts -
#866
d69dd6e
Thanks @juliusmarminge! - feat!: use ingest serverMulti Part Uplaods hasve been abstracted away and files are now uploaded as a single stream to UploadThing, reducing the manual steps required to upload files and improves performance.
Polling has been removed in favor of a streaming upload process with instant feedback
-
#866
d69dd6e
Thanks @juliusmarminge! - chore: update paths to new api domainPreviously the SDK version was just sent in the header which made it cumbersome to make large changes on the API without risking breaking older versions. This change improves our flexibility to make changes to the API without needing to do a major bump on the SDK. It should come with some nice performance wins too!
-
#866
d69dd6e
Thanks @juliusmarminge! - ## 🚨 Breaking ChangesGeneral
- Change
UPLOADTHING_API_KEY
toUPLOADTHING_TOKEN
. The token contains both your API key and some other metadata required by the SDK. You can get a token from the UploadThing dashboard. All options related touploadthingSecret
/apiKey
has now been removed and replaced withtoken
:
- createRouteHandler({ router, config: { uploadthingSecret: 'sk_123' } }) + createRouteHandler({ router, config: { token: 'MY_TOKEN' } }) - new UTApi({ apiKey: 'sk_123' }) + new UTApi({ token: 'MY_TOKEN' })
- If you relied on the
CUSTOM_INFRA_URL
environment variable override, you will have to change this toUPLOADTHING_API_URL
orUPLOADTHING_INGEST_URL
depending on your use case.
uploadthing/client
- Change signature of
genUploader
to return an object instead of a single function.
- const uploadFiles = genUploader(opts) + const { uploadFiles } = genUploader(opts)
- Remove
uploadFiles.skipPolling
option in favor of a new server-side RouteOptionawaitServerData
. If you want your client callback to run as soon as the file has been uploaded,
without waiting for your server sideonUploadComplete
to run, you can now setawaitServerData
tofalse
.
// Client option uploadFiles({ - skipPolling: true }) // Server option const router = { myRoute: f( { ... }, + { awaitServerData: false } ) }
Read more about the new
RouteOptions
in the 📚 Server API Reference docsAdapters
- Change
config.logLevel
levels. Most are now capitalized to match our new logger. Auto-complete should make migrating trivial.
- logLevel: 'info' + logLevel: 'Info'
uploadthing/server
adapter now returns a single function instead of individual named functions. The handler accepts a request and will handle routing internally.
- const { GET, POST } = createRouteHandler({ router, config }) + const handler = createRouteHandler({ router, config })
You can re-export the handler as named functions if your framework requires it.
const handler = createRouteHandler({ router, config }); export { handler as GET, handler as POST };
Features
General
- Add new configuration provider. All config options (e.g.
UTApi.constructor
options orcreateRouteHandler.config
option can now also be set using an environment variable. Setting the option in the constructor is still supported and takes precedence over the environment variable.
const api = new UTApi({ logLevel: "Info", }); // is the same as process.env.UPLOADTHING_LOG_LEVEL = "Info"; const api = new UTApi();
- Change