<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lucas de França</title>
    <description>The latest articles on DEV Community by Lucas de França (@luxonauta).</description>
    <link>https://dev.to/luxonauta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F570897%2Fef24f43b-b6f4-4d5e-a58b-dda2e771da4b.png</url>
      <title>DEV Community: Lucas de França</title>
      <link>https://dev.to/luxonauta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/luxonauta"/>
    <language>en</language>
    <item>
      <title>Beyond Visual: Why We Should Be Using More Haptic Feedback on the Web</title>
      <dc:creator>Lucas de França</dc:creator>
      <pubDate>Thu, 27 Feb 2025 18:46:53 +0000</pubDate>
      <link>https://dev.to/luxonauta/beyond-visual-why-we-should-be-using-more-haptic-feedback-on-the-web-1adg</link>
      <guid>https://dev.to/luxonauta/beyond-visual-why-we-should-be-using-more-haptic-feedback-on-the-web-1adg</guid>
      <description>&lt;p&gt;Visual experiences dominate the web.&lt;/p&gt;

&lt;p&gt;Although most users access the Internet via mobile devices equipped with vibration motors, few web applications use &lt;strong&gt;haptic feedback&lt;/strong&gt; to enrich the user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why touch?
&lt;/h2&gt;

&lt;p&gt;Simply put, our brains process touch faster than sound and vision!&lt;/p&gt;

&lt;p&gt;Research shows that we feel tactile signals in just &lt;code&gt;95ms&lt;/code&gt;, while visual information takes about &lt;code&gt;170ms&lt;/code&gt; to be registered &lt;em&gt;(Ng et al., 2017)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This is why haptic feedback is so fantastic. When you interact with a digital interface through touch and then receive a haptic response, your body instantly feels that connection.&lt;/p&gt;

&lt;p&gt;In studying Human-Computer Interaction (&lt;em&gt;HCI&lt;/em&gt;), researchers even found that interfaces that incorporate haptic feedback have created significant improvements in how we experience tech:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user response speed improves by up to 35% in complex tasks (&lt;em&gt;Brewster &amp;amp; Brown, 2004&lt;/em&gt;);&lt;/li&gt;
&lt;li&gt;Memory retention increases by 23% when combined with visual stimuli (&lt;em&gt;Hoggan et al., 2008&lt;/em&gt;);&lt;/li&gt;
&lt;li&gt;Emotional engagement rises by 27% in satisfaction metrics (&lt;em&gt;Lee &amp;amp; Starner, 2010&lt;/em&gt;);&lt;/li&gt;
&lt;li&gt;Perceived quality and responsiveness of interfaces increase by 40% (&lt;em&gt;Seaborn &amp;amp; Antle, 2011&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When visually impaired users feel haptic feedback from touchscreen elements, they navigate mobile interfaces 28% faster &lt;em&gt;(Kane et al. 2013)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Similarly, &lt;em&gt;Kuber and Yu (2010)&lt;/em&gt; found that when haptic feedback is used with screen readers, people with disabilities understand digital content 32% better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Announcing the &lt;code&gt;useVibration&lt;/code&gt; hook
&lt;/h2&gt;

&lt;p&gt;Many developers shy away from adding vibration because implementing it seems complicated.&lt;/p&gt;

&lt;p&gt;But it's actually pretty simple with the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API" rel="noopener noreferrer"&gt;Vibration API.&lt;/a&gt; But to make it even easier for those who use React, I built the &lt;code&gt;useVibration&lt;/code&gt; hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;useVibration&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;VibrationPatterns&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@luxonauta/use-vibration&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="nx"&gt;isSupported&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isVibrating&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;vibrate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stop&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useVibration&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isSupported&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Vibration not supported on your device&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"button"&lt;/span&gt;
        &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;vibrate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;VibrationPatterns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isVibrating&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isVibrating&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vibrating&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tap me for haptic feedback&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isVibrating&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"button"&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;stop&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Stop Vibration
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/luxonauta/use-vibration" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; | &lt;a href="https://www.npmjs.com/package/@luxonauta/use-vibration" rel="noopener noreferrer"&gt;NPM&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The hook provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Support detection&lt;/strong&gt; - automatically identifying whether the device supports vibration;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Predefined patterns&lt;/strong&gt; - eliminating the need to create patterns from scratch;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimalist API&lt;/strong&gt; - reducing the learning curve for developers;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrated TypeScript&lt;/strong&gt; - providing type safety and auto-completion.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Some design and accessibility considerations
&lt;/h3&gt;

&lt;p&gt;When implementing haptic feedback, developers should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Be unobtrusive&lt;/strong&gt; - vibrations should remain subtle to avoid irritating users;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be consistent&lt;/strong&gt; - the same pattern should always convey the same meaning;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be optional&lt;/strong&gt; - users should be able to turn off haptic feedback;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use in combination&lt;/strong&gt; - never rely solely on haptic feedback.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Current limitations
&lt;/h3&gt;

&lt;p&gt;Unfortunately, vibration support is somewhat inconsistent right now and varies across browsers and devices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Safari &lt;strong&gt;does not support&lt;/strong&gt; the vibration API;&lt;/li&gt;
&lt;li&gt;Desktop browsers generally lack the support;&lt;/li&gt;
&lt;li&gt;And some Android devices may ignore complex patterns.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;However, developers can quickly provide visual or auditory alternatives when needed using the hook's &lt;code&gt;isSupported&lt;/code&gt; check.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The future is multisensory
&lt;/h2&gt;

&lt;p&gt;Haptic feedback represents an opportunity to create more intuitive and accessible interfaces.&lt;/p&gt;

&lt;p&gt;And to cite another study (_Moyes and Jordan, 2021), touch-based interfaces will soon become a key feature distinguishing exceptional digital experiences from mediocre ones.&lt;/p&gt;

&lt;p&gt;When we add thoughtful haptic feedback (or even other options like sound) to our interfaces, we build apps that people will remember and connect with on a deeper, more intuitive level. 🍀&lt;/p&gt;

&lt;h2&gt;
  
  
  💎 References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Ng, Brewster and Williamson (2017) - Study on how mobile device use is affected when occupied with other tasks.&lt;/li&gt;
&lt;li&gt;Brewster and Brown (2004) - How tactile messages (through vibration) can convey information without looking at the screen.&lt;/li&gt;
&lt;li&gt;Hoggan, Brewster and Johnston (2008) - Research on the effectiveness of tactile feedback on touchscreens.&lt;/li&gt;
&lt;li&gt;Lee and Starner (2010) - Study on wrist devices that alert through vibration.&lt;/li&gt;
&lt;li&gt;Seaborn and Antle (2011) - How audio and touch feedback can increase empathy.&lt;/li&gt;
&lt;li&gt;Kane, Wobbrock and Ladner (2013) - Useful gestures for blind people: preferences and performance.&lt;/li&gt;
&lt;li&gt;Kuber and Yu (2010) - Study on touch-based authentication.&lt;/li&gt;
&lt;li&gt;Moyes and Jordan (2021) - How interfaces using multiple senses can be a competitive advantage.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;This is my first one. If you have any suggestions or want to contribute, feel free to do so. I would appreciate it very much! 😊&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>react</category>
      <category>a11y</category>
    </item>
  </channel>
</rss>
