HTMLElement is not defined #405
-
For some reason, getting this error. Installed via npm How do I get the props React using NextJS// Packages
import * as LR from '@uploadcare/blocks'
import { PACKAGE_VERSION } from '@uploadcare/blocks/env'
// Layouts
import Logo from '^/logo'
import config from './upload.module.css'
LR.registerBlocks(LR)
const DesignLayoutsHome = ({ expire, signature }) => {
return (
<section className='p-8 max-w-4xl mx-auto flex flex-col items-center justify-center'>
<Logo />
<div className='flex flex-col gap-8 p-8'>
<lr-file-uploader-inline
className={config?.uploaderCfg}
css-src={`https://unpkg.com/@uploadcare/blocks@${PACKAGE_VERSION}/web/file-uploader-regular.min.css`}
style={{
'--cfg-secure-signature': `"${signature}"`,
'--cfg-secure-expire': `${expire}`
}}
/>
</div>
</section>
)
}
export default DesignLayoutsHome upload.module.css.uploaderCfg {
--ctx-name: 'uploader';
--cfg-pubkey: '<key>'; /* removed for this public post */
--cfg-multiple: 1;
--cfg-confirm-upload: 1;
--cfg-img-only: 0;
--cfg-accept: '';
--cfg-store: 1;
--cfg-camera-mirror: 0;
--cfg-source-list: 'local, url, camera, dropbox, gdrive';
--cfg-max-files: 10;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey @heymartinadams, Depending on your framework, code evaluation should be skipped on the server. In case of Next.js, it could be achieved using one of the following methods:
As for the
|
Beta Was this translation helpful? Give feedback.
-
Hey @heymartinadams , We have added a separate bundle for SSR that will work with static import and won't raise an error on Next.js. Please try updating to |
Beta Was this translation helpful? Give feedback.
Hey @heymartinadams,
Depending on your framework, code evaluation should be skipped on the server.
In case of Next.js, it could be achieved using one of the following methods:
"use client"
directive, see https://beta.nextjs.org/docs/rendering/server-and-client-componentsimport('@uploadcare/blocks').then(m => m.registerBlocks(m))
connectBlocksFrom
helper, see https://uploadcare.github.io/blocks/get-started/installation/ -connectBlocksFrom('https://cdn.jsdelivr.net/npm/@uploadcare/[email protected]/web/blocks-browser.min.js');
As for the
expire
andsignature
, you should wrapexpire
into the quotes too.