Diwali lights for React, Next.js and Vue apps
Diwali Lights is framework-free: one async script that draws on its own canvas overlay. It doesn't touch your component tree or your CSS, so it works the same in React, Next.js, Vue, Svelte, Angular or a static site.
You'll need your free key first. It takes a minute and arrives by email.
Step by step
Get your free key
Register your production domain at worldofaiagents.com/diwali and verify your email. Keys also work on
localhostfor development.Add the script
Use the snippet for your framework below. Load it once per app, not inside components that re-render.
Optional: control it from code
The widget exposes
window.DiwaliLightswithsetStyle(),burst(),celebrate(),on()andoff().
Your code looks like this
<script async src="https://worldofaiagents.com/diwali/w.js" data-key="DL-YOURKEY" data-style="grand"></script>
Change data-style to diyas, fireworks, toran, lanterns or grand whenever you like. Optional: data-sparkler="off" removes the cursor sparkler, data-until="2026-11-20" switches the lights off after a date, and data-position="right" moves the small on/off button.
Next.js (App Router)
// app/layout.tsx
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
<Script src="https://worldofaiagents.com/diwali/w.js" strategy="afterInteractive"
data-key="DL-YOURKEY" data-style="grand" />
</body>
</html>
);
}
React (Vite / Create React App)
Paste the script tag into index.html just before </body>:
<script async src="https://worldofaiagents.com/diwali/w.js" data-key="DL-YOURKEY" data-style="grand"></script>
Vue / Nuxt
// nuxt.config.ts
export default defineNuxtConfig({
app: { head: { script: [{ src: 'https://worldofaiagents.com/diwali/w.js', async: true,
'data-key': 'DL-YOURKEY', 'data-style': 'grand', tagPosition: 'bodyClose' }] } }
});
Control it from your app
window.DiwaliLights.setStyle('fireworks'); // diyas | fireworks | toran | lanterns | grand
window.DiwaliLights.celebrate(); // a volley of fireworks, e.g. after checkout
window.DiwaliLights.burst(x, y); // one burst at a screen position
window.DiwaliLights.off(); // and .on()
addEventListener('diwalilights:ready', e => console.log(e.detail.style));
Troubleshooting
- It loads twice in development
- React Strict Mode double-mounts components. Load the script from layout or index.html, not from a component effect. The widget also ignores a second copy.
- TypeScript complains about window.DiwaliLights
- Declare it:
declare global { interface Window { DiwaliLights?: any } }.
Questions
Is there an npm package for a Diwali animation?
You don't need one. Diwali Lights is a hosted script that stays up to date, so you add one tag instead of a dependency, and it works in any framework.
Does it work with server-side rendering?
Yes. The script runs only in the browser after the page loads, so it has no effect on SSR, hydration or your bundle size.
Light up your React & Next.js site today
The lights on this page are the real widget. Try every style on the main page.
Get my free Diwali lights 🪔Other guides
- Add Diwali lights to your WordPress website
- Add Diwali lights to your Shopify store
- Add Diwali lights to your Wix website
- Add Diwali lights to your Squarespace website
- Add Diwali lights to your Webflow site
- Add Diwali lights to your Blogger blog
- Add Diwali lights with Google Tag Manager
- Deepavali decoration for your website