Skip to content

Svelte / Vanilla JS Trustpilot Widget with proper SPA support

License

Notifications You must be signed in to change notification settings

beyonk-group/svelte-trustpilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation





Svelte Trustpilot

js-standard-style CircleCI svelte-v2 svelte-v3

Pure vanilla JS Trustpilot integration

trustpilot

Install

$ npm install --save-dev @beyonk/svelte-trustpilot

Usage (With Svelte)

<Trustpilot businessUnit="12345" domain="www.example.com"  />

<script>
  import Trustpilot from '@beyonk/svelte-trustpilot'
</script>

The attributes you pass to the Trusilot component are listed below, but you need domain and businessUnit at a minimum.

Usage (Vanilla JS)

<div id="trustpilot-wrapper"></div>

<script>
  import Trustpilot from '@beyonk/svelte-trustpilot'

	const trustpilot = new Trustpilot({
		target: document.querySelector('#trustpilot-wrapper'),
		data: {
			businessUnit: '12345',
			domain: 'www.example.com'
		}
	})
</script>

Other configuration attributes

There are a number of configuration attributes you can pass, but all are optional.

List of possible options in the module:

Option Default Required Description
widget (1) micro-star false Widget type as per [https://businessapp.b2b.trustpilot.com/?locale=en-US#/integrations/trustbox/library](Trustpilot Trustbox library)
domain - true Sets the domain/product name on Trustpilot (for the link when a user clicks your widget)
businessUnit - true Sets data-businessunit-id as per docs
width 100% false Sets data-style-width as per docs
height 500px false Sets data-style-height as per docs
theme dark false Sets data-theme as per Trustpilot docs
lib package-name false Unique id to determine if component is loaded. You probably don't need to change this.
version v5 false Trustpilot SDK version (best not to change)
* (2) - false Pass any other parameter you want here. See below.
  1. You can pass any widget template name in its hyphenated form, or, just pass the template id here instead. You can get the template id from the trustpilot integration url:

https://businessapp.b2b.trustpilot.com/?locale=en-US#/integrations/trustbox/configuration/<widget-id-is-here>

  1. You can pass any data- attribute you normally pass to Trustpilot's widgets. These will be passed verbatim to the underlying widget HTML.

License

MIT License