create account

Unleash the Power of Termly in Your NextJS App Project! by coininstant

View this thread on: hive.blogpeakd.comecency.com
· @coininstant · (edited)
$6.55
Unleash the Power of Termly in Your NextJS App Project!
![termly-nextjs.png](https://files.peakd.com/file/peakd-hive/coininstant/Ep3Y7YEXXjSCgRgJiY1UpjGx4YnMBYpL76LX23XNacqP19puzbNtcdfvqLuYELkW7Vq.png)

I've been relatively quiet on HIVE lately, this is because the rise of AI has kept me immersed in a world of new tools and technologies. I have mainly been working on building website projects to integrate with HIVE, keep reading to the end of this post and I will share a link to the site I'm working on.  Amidst my busy schedule, I'm eager to share some of the intriguing and valuable insights I've learned along the way. I was quite surprised at how involved it was adding a simple one-page Termly privacy policy to my Nextjs web app. so here's the lowdown of the various processes involved below. Let's dive in.

Step 1.  Sign up with Termly for free here: https://app.termly.io/

Step 2. Select the type of Terms and conditions that match your site by letting Termly scan your entire website. Next, you will be prompted with various questions, once you answer all the questions Termly will create your specific page.

![Screenshot 2023-12-28 at 8.37.29 PM.png](https://files.peakd.com/file/peakd-hive/coininstant/23uRBV6b3pTcXFc53hSnqiRxqhUUFfci1sY3Z4RF42ynPC9eoTwZfMmYrGwMo9NJigqzq.png)

Step 3. Copy the HTML code provided by Termly by clicking ADD TO WEBSITE,  and then click, COPY TO CLIPBOARD. Be sure to paste it in a text editor, or notes, somewhere you can separate the two major parts.  It’s a huge file, so don’t be intimidated, the top is the style sheet (in the green square below), and the bottom of the file is the HTML portion.

![Screenshot 2023-12-28 at 8.40.18 PM.png](https://files.peakd.com/file/peakd-hive/coininstant/23tGY4gqJmSdios5FaeyBXXz6zLUZoRqxdUVVMra2KEEcwVZe6jF8nsqukEwv6S26wpLi.png)
...
![Screenshot 2023-12-28 at 9.25.27 PM.png](https://files.peakd.com/file/peakd-hive/coininstant/EoATUJFL6EB8jkTRKLajdw4ofjQdTuDZ1Mwy13brNBMzNEw4uEAzF4Ad3438SJzMixQ.png)
Step 4. Convert the HTML section to JSX for working in NextJS. I found a nifty site to do this, it’s called https://transform.tools/html-to-jsx


![Screenshot 2023-12-28 at 8.42.12 PM.png](https://files.peakd.com/file/peakd-hive/coininstant/Eo8Z8um5MpzHj5CHsv2ZYXYsvcafXNxPXPxuLHMAwCjvnZzVfuhdTmNsmoi4E6BGwN5.png)


Remember to only convert the HTML to JSX, and leave the style sheet portion alone for now.


Step 5. Now, it’s time to open up our Next.js app and create a component, in the pages directory. This is where we will integrate the converted JSX code we generated in the previous step, along with its associated styles that we initially copied directly from Termly.  Since Termly provides a separate stylesheet for styling the privacy policy, there are a few options for integrating it into your Next.js app. You can either use a global stylesheet and make sure to import it to your page, or simply create a component-specific style sheet, which is the route I took for this example. Later on, if I find out that the style sheets are not specific to each Termly policy I could pull the styles out and use one global stylesheet to service all the pages.  Here is the in-line component-specific style sheet component code snippet example that I used below:






```
'use client'

import React from 'react';

const PrivacyPolicy = () => (
  <div>
    <style jsx>{`
      [data-custom-class='body'], [data-custom-class='body'] * {
        background: transparent !important;
      }
      /* ... other styles ... */
    `}</style>
    {/* Your component content */}
  </div>
);

export default PrivacyPolicy;
```

What you want to do is copy the style sheet ( I made a green square around the pertinent part in the image above) in-between the ``` <style jsx>{` ``` copy styles here   ``` `}</style> ```    tags.


![Screenshot 2023-12-28 at 9.15.42 PM.png](https://files.peakd.com/file/peakd-hive/coininstant/23t75BP29U5NsSqjsqavfNfcN12VCqek7TvBAnUezQPWGh6k31VstpRW7cNMALusAj273.png)



Next, paste your JSX code where it says *Your Component Content* in that same component code snippet. This part is easy, it’s just a bunch of div tags, here is the view of the bottom of the file in my code editor. Look how long this file is, I think it’s reaching the limit of Visual Studio code… lol Working with these long files can be a challenge in themselves.


![Screenshot 2023-12-28 at 9.26.38 PM.png](https://files.peakd.com/file/peakd-hive/coininstant/23swfwMHQDeXW3KyPLqKpyK23MSBTcqVePDFuyypxeAohARfvFK3cqLTzuWd78MGnx5Qc.png)


Step 6. Add a little padding to the very first div tag.
```
}</style>
    <div data-custom-class="body" style={{ padding: '0 60px' }}>
  <div>
```
I used 60 pixels because the page was coming out close to the left and right margin by default. Refer to image…
![Screenshot 2023-12-28 at 9.30.12 PM.png](https://files.peakd.com/file/peakd-hive/coininstant/Eo6CDgKRTWi1euAyaWohKAk1aCWReTPigzJ3o7qpKSBs5fiVbmgKPgyE58yW6cbmnAt.png)


Step 7. At this point you should still be seeing error messages like Property 'bdt' does not exist on type 'JSX.IntrinsicElements'. Property 'bdt' does not exist on type 'JSX.IntrinsicElements'.  This is ok, that means you are on the right track. The error message is related to TypeScript and JSX (JavaScript XML). This error typically occurs when you're trying to use a property or attribute called 'bdt' on a JSX element, but TypeScript can't find it in the type definitions for JSX.IntrinsicElements. Therefore in this case, since Termly uses BDT we must Extend JSX.IntrinsicElements.

Since 'bdt' is not a standard HTML attribute and we want to use it in JSX, we can extend the JSX.IntrinsicElements type to include our custom properties. This is often done by creating a global.d.ts file and declaring the additional properties there. So to fix this issue we must add a file named global.d.ts to the root (main folder) of our project. If you don't already have one, create this file now and paste the following code snippet into it to tell TypeScript that 'bdt' is a valid property for JSX elements.
```
// global.d.ts
declare namespace JSX {
  interface IntrinsicElements {
    // Add your custom properties here
    bdt: any;
  }
}
```

Step 8.
Include in tsconfig.json:
Ensure that your tsconfig.json file includes the global.d.ts file in the "files" or "include" section. If you don't have a tsconfig.json file, you may need to create one.
``` 
{
  "compilerOptions": {
    // Your compiler options here
  },
  "files": [
    "global.d.ts"
  ],
  // OR
  "include": [
    "global.d.ts",
    // Other files and directories
  ]
}
```




Step 9. Build your app. You can check your new page in the development server, however, it won’t compile yet because of one last issue, and the issue has to do with some characters that https://transform.tools/html-to-jsx may have missed. Online tools like html-to-jsx often do a great job of converting HTML to JSX, but they might not catch every single minute detail, especially when it comes to escaping characters. It's always a good practice to review the output and make any necessary adjustments, especially when dealing with characters that have special meaning in JSX or HTML.

In these long-winded privacy notices, Termly likes to use a lot of quotes and apostrophes, and the compiler does not like it. If you see errors like the ones below, it’s time to pat yourself on the back because it means you are on the home stretch. Here is what you may see when getting to this stage while working on a Termly policy page…
```
Failed to compile.

./src/app/pages/privacypolicy/page.tsx
87:47  Error: `"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`.  react/no-unescaped-entities
87:68  Error: `"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`.  react/no-unescaped-entities
87:70  Error: `"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`.  react/no-unescaped-entities
88:31  Error: `"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`.  react/no-unescaped-entities
88:36  Error: `"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`.  react/no-unescaped-entities
88:57  Error: `"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`.  react/no-unescaped-entities
93:46  Error: `"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`. 

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

The error messages above are related to ESLint and the react/no-unescaped-entities rule. This rule is designed to catch unescaped HTML entities within JSX to prevent certain types of XSS (cross-site scripting) vulnerabilities. The error message indicates that you have unescaped characters (like quotes or apostrophes) in your JSX, and it's suggesting to escape them using HTML entities.

To address this issue simply Escape the Characters: Identify the locations in your JSX where the unescaped characters are present, and replace them with their corresponding HTML entities. Luckily with Visual Studio Code, you can just hover over each error and a link will pop up and take you there.

For example: to escape these quotes with ```&quot; ``` 

``` 
<bdt className="block-component" />"<strong>we</strong>," "
          <strong>us</strong>," or "<strong>our</strong>" 
```

You would change the above line of code to the line below…..
```
<bdt className="block-component" />&quot;<strong>we</strong>,&quot; &quot;<strong>us</strong>,&quot; or &quot;<strong>our</strong>&quot;

```

So do this about 50 more times because that’s how many there will probably be. I’m sure there will be some genius out there who knows how to find them all way quicker, if you know how please be sure to leave a comment down below.


Here's a simpler example. If you need to escape apostrophes in the word "Consumer's" within JSX, you can use the HTML entity &rsquo; for the apostrophe. Here's how you can modify the code:
```
<span data-custom-class="body_text">
  <u>
    Right to Non-Discrimination for the Exercise of a Consumer&rsquo;s Privacy Rights
  </u>
</span>
```
By now you should get the gist of escaping special characters to get your pages to work.. After escaping all the characters in the error log, that’s it, we’re finished.  And here's what the finished page looks like on my project, you can check it out at the link below:
https://heliosmarket.io/pages/privacypolicy

HeliosMarket.io is the website I've been working on, it has been my playground for exploring the endless possibilities of what I can create with AI by my side.  Looking ahead, the roadmap for HeliosMarket can be long, it extends to the integration of HIVE payments, and much more. Thanks to the availability of AI, much more is possible than I ever dreamed, so stay tuned and follow me for tips and tricks I learn along the way. Any questions, feel free to leave them in the comments section below.


# Follow @coininstant for more!
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 58 others
properties (23)
authorcoininstant
permlinkunleash-the-power-of-termly-in-your-nextjs-app-project
categorytribes
json_metadata"{"app":"peakd/2023.11.3","description":"How to create a privacy policy with Termly for NextJS!","format":"markdown","image":["https://files.peakd.com/file/peakd-hive/coininstant/Ep3Y7YEXXjSCgRgJiY1UpjGx4YnMBYpL76LX23XNacqP19puzbNtcdfvqLuYELkW7Vq.png","https://files.peakd.com/file/peakd-hive/coininstant/23uRBV6b3pTcXFc53hSnqiRxqhUUFfci1sY3Z4RF42ynPC9eoTwZfMmYrGwMo9NJigqzq.png","https://files.peakd.com/file/peakd-hive/coininstant/23tGY4gqJmSdios5FaeyBXXz6zLUZoRqxdUVVMra2KEEcwVZe6jF8nsqukEwv6S26wpLi.png","https://files.peakd.com/file/peakd-hive/coininstant/EoATUJFL6EB8jkTRKLajdw4ofjQdTuDZ1Mwy13brNBMzNEw4uEAzF4Ad3438SJzMixQ.png","https://files.peakd.com/file/peakd-hive/coininstant/Eo8Z8um5MpzHj5CHsv2ZYXYsvcafXNxPXPxuLHMAwCjvnZzVfuhdTmNsmoi4E6BGwN5.png","https://files.peakd.com/file/peakd-hive/coininstant/23t75BP29U5NsSqjsqavfNfcN12VCqek7TvBAnUezQPWGh6k31VstpRW7cNMALusAj273.png","https://files.peakd.com/file/peakd-hive/coininstant/23swfwMHQDeXW3KyPLqKpyK23MSBTcqVePDFuyypxeAohARfvFK3cqLTzuWd78MGnx5Qc.png","https://files.peakd.com/file/peakd-hive/coininstant/Eo6CDgKRTWi1euAyaWohKAk1aCWReTPigzJ3o7qpKSBs5fiVbmgKPgyE58yW6cbmnAt.png"],"tags":["tribes","pob","alive","aliveandthriving","hive"],"users":["coininstant"]}"
created2023-12-29 19:51:15
last_update2023-12-31 09:44:09
depth0
children9
last_payout2024-01-05 19:51:15
cashout_time1969-12-31 23:59:59
total_payout_value3.199 HBD
curator_payout_value3.349 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length11,146
author_reputation88,251,055,788,412
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries
0.
accountpeakd
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,075,340
net_rshares14,136,070,985,077
author_curate_reward""
vote details (122)
@acidyo ·
You may wanna check what people are doing with your stake: https://peakd.com/hive-131951/@helios.voter/re-danielvehe-s6poia
properties (22)
authoracidyo
permlinkre-coininstant-s6pvjg
categorytribes
json_metadata{"tags":["tribes"],"app":"peakd/2023.11.3"}
created2024-01-04 03:11:42
last_update2024-01-04 03:11:42
depth1
children4
last_payout2024-01-11 03:11:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length123
author_reputation3,367,995,550,645,330
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,207,293
net_rshares0
@coininstant ·
Bro I am helios.voter, thanks for the tip! Just because someone accuses someone else of doing something doesn't make them right. Daniel is spreading false accusations and slandering my project so I was defending our community with our stake. Thanks for trying to help but nothing is going on.
properties (22)
authorcoininstant
permlinkre-acidyo-s6qa2k
categorytribes
json_metadata{"tags":["tribes"],"app":"peakd/2023.11.3"}
created2024-01-04 08:25:39
last_update2024-01-04 08:25:39
depth2
children3
last_payout2024-01-11 08:25:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length292
author_reputation88,251,055,788,412
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,211,020
net_rshares0
@acidyo ·
If someone goes and reports a project or account to hivewatcher it doesn't give people the right to go on a downvote spree and threaten to downvote someone forever, especially when they don't have a history of starting drama or wanting bad things for hive, on the contrary. Furthermore, the curation of helios.voter is really questionable, so many accounts with close to no comments posting questionable content if it's original or just copy-pasted/spun, even if it was original if there is no consumption since there are no followers/readers and the authors aren't making an effort it doesn't justify the rewards. Not even going to get into the basis of what the token does and what you can do with it, just a bad idea in general for proof of brain. 
properties (22)
authoracidyo
permlinkre-coininstant-s6qads
categorytribes
json_metadata{"tags":["tribes"],"app":"peakd/2023.11.3"}
created2024-01-04 08:32:18
last_update2024-01-04 08:32:18
depth3
children2
last_payout2024-01-11 08:32:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length751
author_reputation3,367,995,550,645,330
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,211,133
net_rshares0
@claudio83 ·
@tipu curate
properties (22)
authorclaudio83
permlinkre-coininstant-s6g20g
categorytribes
json_metadata{"tags":["tribes"],"app":"peakd/2023.11.3"}
created2023-12-29 19:55:30
last_update2023-12-29 19:55:30
depth1
children1
last_payout2024-01-05 19:55:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length12
author_reputation1,894,787,512,784,354
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,075,405
net_rshares0
@tipu ·
<a href="https://tipu.online/hive_curator?claudio83" target="_blank">Upvoted  &#128076;</a> (Mana: 22/52) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-coininstant-s6g20g-20231229t195535z
categorytribes
json_metadata"{"app": "beem/0.24.26"}"
created2023-12-29 19:55:36
last_update2023-12-29 19:55:36
depth2
children0
last_payout2024-01-05 19:55:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length217
author_reputation55,949,689,035,458
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,075,406
net_rshares0
@tahirazaman ·
Excellent informative post I am waiting for your posting 
properties (22)
authortahirazaman
permlinkre-coininstant-20231230t450789z
categorytribes
json_metadata{"type":"comment","tags":["tribes","pob","alive","aliveandthriving","hive"],"app":"ecency/3.0.44-mobile","format":"markdown+html"}
created2023-12-29 23:50:06
last_update2023-12-29 23:50:06
depth1
children0
last_payout2024-01-05 23:50:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length57
author_reputation66,719,258,943,294
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,079,383
net_rshares0
@theguruasia ·
$WINE
properties (22)
authortheguruasia
permlinkre-coininstant-s6giy5
categorytribes
json_metadata{"tags":["tribes"],"app":"peakd/2023.11.3"}
created2023-12-30 02:01:12
last_update2023-12-30 02:01:12
depth1
children0
last_payout2024-01-06 02:01:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5
author_reputation72,600,982,981,532
root_title"Unleash the Power of Termly in Your NextJS App Project!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id130,081,255
net_rshares0