Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script Component does not work in next.js

I'm working in Tiny Editor, it's necessary to define a key for the editor, following the documentation I can consult this key through the tag <script src = 'address', that's how it works, but when joining the Script component of the next .js (< Script src = 'address') I can't communicate with tiny anymore, has anyone been through this?

# It works
<script src='address' />

# Does not work
<Script src='address' />

doc: https://nextjs.org/docs/basic-features/script

like image 338
Edson Junior Avatar asked Feb 11 '26 02:02

Edson Junior


1 Answers

  • If Script component is inside <Head> component, use it outside <Head>

  • Try in a different browser. It might be browser-specific issue

  • default value for the strategy prop is afterInteractive. with this, script is fetched and executed after the page is interactive. Use beforeInteractive for critical scripts that need to be fetched and executed before the page is interactive.

  • use onError props for debugging.

     onError={(e) => {
            console.error('Script failed to load', e)
          }}
    
like image 68
Yilmaz Avatar answered Feb 13 '26 17:02

Yilmaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!