There are two ways to do this:
1. Modify the index.html
File:
In your public/index.html
file, configure Beamer to initialize lazily by adding the lazy: true
parameter to the beamer_config
object:
htmlCopy code<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Your App Title</title><!-- Beamer Script --><script> var beamer_config = { product_id : 'your_product_id', lazy: true };</script><script type="text/javascript" src="https://app.getbeamer.com/js/beamer-embed.js" defer="defer"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
2. Update User Data and Initialize Beamer in React:
Once user data is available in your React application, you can call the Beamer.update()
method to pass in the user details and initialize Beamer.
Example:
jsxCopy codeimport React, { useEffect } from 'react';function App() { useEffect(() => { // Assuming user data is retrieved here const userData = { user_id: '1234', user_firstname: 'Jane', user_lastname: 'Doe', user_email: 'jdoe@rollstack.com' }; // Check if Beamer is available on the window object if (window.Beamer) { window.Beamer.update(userData); } }, []); return ( <div id="root"> {/* Your app content */} </div> ); } export default App;
1. Install React Helmet:
If you haven’t already installed react-helmet, you can do so using npm or yarn:
npm install react-helmet# oryarn add react-helmet
2. Locate the Component Where You Want to Embed Beamer:
You can add the Beamer script in the root component (e.g., App.jsx) or any other component that is rendered at the start of your application.
3. Import and Use React Helmet:
In the selected component, import Helmet from react-helmet and inject the Beamer script with the user-specific data.
<script>import React from 'react';import { Helmet } from 'react-helmet';function App() { // Replace these with actual user data const userEmail = "user@example.com"; const userName = "John Doe"; return (<><Helmet><script> {` var beamer_config = { product_id : 'your_product_id', user_email: '${userEmail}', user_name: '${userName}' }; `}</script><script src="https://app.getbeamer.com/js/beamer-embed.js" defer="defer"></script></Helmet> {/* Rest of your app */}<div id="root"> {/* Your app content */}</div></>); } export default App;
4. Run Your Application:
npm start
or yarn start
.Help us help you more
At Beamer, we care about our customers’ data and this is how we protect it.
Data Ownership
Your account and data belongs to you and will not be sold in any case. We can delete your account and data upon your request. Learn more
Encryption
Beamer data is encrypted in transit (advanced TLS protocols and 2,048-bit keys or better) and at rest (using AES 256 encryption with integrity).
Access
Customer data is always backed up and uptime is over 99.9%.
GDPR
Beamer is GDPR Compliant and has the Data Processing Agreements in place. Learn more
Penetration testing
Third party network, application and physical security tests are conducted regularly. Learn more