<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ashhar Akhlaque]]></title><description><![CDATA[Ashhar Akhlaque]]></description><link>https://ashhar-akhlaque.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 22:11:30 GMT</lastBuildDate><atom:link href="https://ashhar-akhlaque.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Add proctoring to a React quiz in five lines]]></title><description><![CDATA[TL;DR: npm install proctorkit, add a page key, create one proctor per candidate and call runChecks() then start() from your Start button. Recording only is…]]></description><link>https://ashhar-akhlaque.hashnode.dev/add-proctoring-to-a-react-quiz-in-five-lines</link><guid isPermaLink="true">https://ashhar-akhlaque.hashnode.dev/add-proctoring-to-a-react-quiz-in-five-lines</guid><category><![CDATA[React]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Ashhar Akhlaque]]></dc:creator><pubDate>Thu, 03 Dec 2026 06:16:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0b5fa2d4896e18e24c1a4f/c3030b66-96a5-4a7b-8662-d5f42565a598.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p><strong>TL;DR:</strong> <code>npm install proctorkit</code>, add a page key, create one proctor per candidate and call <code>runChecks()</code> then <code>start()</code> from your Start button. Recording only is free during launch. AI review is ₹15 ($0.25) per candidate session, with the first 50 free.</p>
</blockquote>
<p>Most cheating in online tests is casual, and most proctoring only starts at the interview. I wanted every candidate's first-round test covered, and I didn't want to move the questions into someone else's platform. This is the React version of how I added it to a hiring test we already had.</p>
<p><strong>Before the code:</strong> it runs in desktop Chrome or Edge only. It's built for everyday cheating (a phone, a friend, an AI chat in the next tab, and 20+ other checks), not determined attackers. What it doesn't see:</p>
<table>
<thead>
<tr>
<th>Not covered</th>
<th>Why</th>
</tr>
</thead>
<tbody><tr>
<td>A phone fully outside the camera's view</td>
<td>The camera can't see it</td>
</tr>
<tr>
<td>Tools built to hide from screen sharing</td>
<td>They don't show up in the shared screen</td>
</tr>
<tr>
<td>Someone speaking off camera</td>
<td>Nothing on screen or camera shows it</td>
</tr>
</tbody></table>
<h2>See it in action</h2>
<p><a class="embed-card" href="https://youtu.be/47Efm9vw8hk">https://youtu.be/47Efm9vw8hk</a></p>

<h2>What you get</h2>
<ul>
<li>A system check and a consent screen before the first question</li>
<li>Full screen, the entire screen shared and the camera on, for the whole test</li>
<li>The recording and every event tied to the question on screen</li>
<li>With AI review on, a report per candidate, riskiest first</li>
</ul>
<p>Your questions, answers and scoring stay where they are. You can sign up, add the code and proctor real candidates the same day, with no sales call.</p>
<h2>1. Install</h2>
<pre><code class="language-bash">npm install proctorkit
</code></pre>
<h2>2. Get a page key</h2>
<p>Create an account at <a href="https://proctorkit.com">proctorkit.com</a>, choose Record or Record + AI review, and add the website your quiz runs on. You get a key that starts with <code>pk_pub_</code>. It's safe in the page: it only works on the websites you list, and on localhost while you build.</p>
<h2>3. One proctor per candidate</h2>
<pre><code class="language-ts">// proctor.ts
import { createProctor } from 'proctorkit';

export const makeProctor = (user: { id: string; name: string; email?: string }) =&gt;
  createProctor({
    key: import.meta.env.VITE_PROCTORKIT_KEY,
    candidate: user,
    test: { id: 'round-1', name: 'Screening round 1' },
  });
</code></pre>
<h2>4. Start it from your Start button</h2>
<pre><code class="language-tsx">const [proctor] = useState(() =&gt; makeProctor(user));
const [started, setStarted] = useState(false);

const begin = async () =&gt; {
  const check = await proctor.runChecks(); // system check and consent
  if (check.ok &amp;&amp; proctor.start()) setStarted(true);
  else setProblem(check.reason ?? 'not ready'); // e.g. 'unsupported', 'camera'
};

useEffect(() =&gt; {
  if (started) proctor.setContext({ questionId: questions[i].id });
}, [started, i]);

const submit = () =&gt; {
  proctor.stop(); // releases camera and screen
  // ...save the answers as you do today
};
</code></pre>
<p><code>runChecks()</code> has to run from a click, because browsers only allow screen sharing and full screen after one.</p>
<h2>5. A timer that stops during pauses</h2>
<p>If the candidate leaves full screen or stops sharing, the test pauses until they fix it. Base your countdown on <code>activeMs()</code>, which leaves out paused time:</p>
<pre><code class="language-ts">const left = limitMs - proctor.activeMs();
</code></pre>
<h2>6. See the results</h2>
<p>Each candidate shows up in your dashboard under their test, with the recording and flags laid out by question. With AI review on, the riskiest sessions come first.</p>
<h2>What it costs</h2>
<p>Recording only is free during launch. AI review is ₹15 ($0.25) per candidate session, with the first 50 free. No subscription.</p>
<h2>Try it</h2>
<p>Try to cheat the five-question demo (desktop Chrome or Edge), then read the report it writes about you: <a href="https://proctorkit.com/demo">proctorkit.com/demo</a>. On your phone? Start at <a href="https://proctorkit.com">proctorkit.com</a> and save the demo for your laptop. Full guide: <a href="https://proctorkit.com/docs/react/">proctorkit.com/docs/react</a>.</p>
]]></content:encoded></item></channel></rss>