Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
How to import external js library (cdn) to react typescript project?

I need to import https://youglish.com/public/emb/widget.js to my React project and use its YG as a function. Basically, I need this widget in my React web app. I was able to use its tag. but I need to get the YG function into React app.

you may also consider https://youglish.com/api/doc/js-api

Methods I have tried so far!

1.

import 'https://youglish.com/public/emb/widget.js'

const Widget = () => {
    const widget = new YG.Widget("widget-1");
    widget.fetch("courage", "english");
  };

  return (
    <>
      <Widget />

.....
import YG from "YG";

 useEffect(() => {
    const script = document.createElement("script");
    script.src = "https://youglish.com/public/emb/widget.js";
    script.async = true;
    document.body.appendChild(script);
  }, []);

const Widget = () => {
    const widget = new YG.Widget("widget-1");
    widget.fetch("courage", "english");
  };

  return (
    <>
      <Widget />

.....

added in index.html dody
<script
      async
      src="https://youglish.com/public/emb/widget.js"
      charset="utf-8"
    ></script>

errors: 
Failed to compile.

./src/App.tsx
Module not found: Can't resolve 'YG' in '/Users/.../Documents/Apps/Projects/.../src'
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda