0%
FrontEnd

Building Bobologia - Applying React.js Best Practices for a High-Performance Therapy Platform

Hassan Djirdeh & Jacek Leszczyński Hassan Djirdeh & Jacek Leszczyński
6 min read

In the fast-evolving world of web development, creating a user-centric, high-performance platform is essential for businesses like therapy practices, where accessibility and trust are paramount. Bobologia, a website developed for licensed therapist Marta Konarzewska, exemplifies how modern React.js best practices can deliver a fast, accessible, and SEO-friendly platform. Launched on August 4, 2025, Bobologia leverages React.js and Astro.js to achieve near-perfect Lighthouse scores (~100) across performance, accessibility, SEO, and best practices, while driving significant client growth through optimized search visibility. This article explores the key React.js techniques used to build Bobologia, offering insights into building scalable, user-focused web solutions.

Bobologia therapy website with modern, responsive design

Core React.js Best Practices

Use Function Components for Simplicity

Function components, powered by React hooks, form the backbone of Bobologia’s frontend. They simplify development, enhance composability, and align with modern React standards, moving away from the complexity of class components. For instance, the appointment booking component uses useState and useEffect to manage dynamic state efficiently:

import React, { useState, useEffect } from 'react';

function AppointmentBooking({ therapistId }) {
  const [appointments, setAppointments] = useState([]);

  useEffect(() => {
    fetch(`/api/therapists/${therapistId}/appointments`)
      .then(response => response.json())
      .then(data => setAppointments(data));
  }, [therapistId]);

  return (
    <div>
      {appointments.map(appointment => (
        <div key={appointment.id}>{appointment.time}</div>
      ))}
    </div>
  );
}

This approach ensures clean, maintainable code, reducing boilerplate and improving readability.

Leverage Custom Hooks for Reusability

Custom hooks are a powerful way to encapsulate reusable logic, making the codebase modular and easier to maintain. In Bobologia, a custom hook manages form input for the appointment scheduling feature, promoting code reuse across multiple forms:

import { useState } from 'react';

function useAppointmentForm(initialValue) {
  const [formData, setFormData] = useState(initialValue);

  function handleChange(e) {
    setFormData({ ...formData, [e.target.name]: e.target.value });
  }

  return { formData, handleChange };
}

function AppointmentForm() {
  const { formData, handleChange } = useAppointmentForm({ date: '', time: '' });

  return (
    <form>
      <input name="date" value={formData.date} onChange={handleChange} />
      <input name="time" value={formData.time} onChange={handleChange} />
    </form>
  );
}

This hook enhances scalability by allowing form logic to be reused across different components, streamlining development.

Use Context API for Theme Management

Bobologia’s automatic light/dark mode feature, which syncs with the user’s device theme, is implemented using the Context API. This approach avoids prop drilling and ensures a seamless, accessible user experience:

import React, { createContext, useState, useEffect } from 'react';

const ThemeContext = createContext();

function App() {
  const [theme, setTheme] = useState('light');

  useEffect(() => {
    const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
    setTheme(prefersDark ? 'dark' : 'light');
  }, []);

  return (
    <ThemeContext.Provider value={{ theme }}>
      {/* Rest of the app */}
    </ThemeContext.Provider>
  );
}

function ThemedComponent() {
  const { theme } = useContext(ThemeContext);
  return <div className={theme === 'light' ? 'bg-white text-black' : 'bg-gray-800 text-white'}>Content</div>;
}

This implementation respects user preferences, enhancing accessibility and user comfort.

TypeScript for Robust Development

Type-Safe Components with TypeScript

TypeScript was integrated into Bobologia to ensure type safety, catching errors early and improving code clarity. For example, the appointment card component uses typed props to enforce structure:

interface Appointment {
  id: number;
  time: string;
  client: string;
}

interface AppointmentCardProps {
  appointment: Appointment;
  onCancel: () => void;
}

function AppointmentCard({ appointment, onCancel }: AppointmentCardProps) {
  return (
    <div>
      <p>{appointment.time} - {appointment.client}</p>
      <button onClick={onCancel}>Cancel</button>
    </div>
  );
}

TypeScript’s static typing reduces runtime errors and boosts developer confidence, especially in complex applications.

Type-Safe Custom Hooks

Custom hooks in Bobologia also leverage TypeScript generics for flexibility and safety. For instance, a local storage hook ensures type consistency across different data types:

function useLocalStorage<T>(key: string, initialValue: T): [T, (value: T) => void] {
  const [storedValue, setStoredValue] = useState<T>(() => {
    try {
      const item = window.localStorage.getItem(key);
      return item ? JSON.parse(item) : initialValue;
    } catch (error) {
      console.error(error);
      return initialValue;
    }
  });

  const setValue = (value: T) => {
    try {
      setStoredValue(value);
      window.localStorage.setItem(key, JSON.stringify(value));
    } catch (error) {
      console.error(error);
    }
  };

  return [storedValue, setValue];
}

This approach makes hooks reusable and robust, maintaining type safety across the application.

Performance Optimization with Astro.js

Near-Perfect Lighthouse Scores

Bobologia combines React.js for dynamic components with Astro.js for static site generation, achieving near-perfect Lighthouse scores (~100) across performance, accessibility, SEO, and best practices. Astro.js minimizes JavaScript payload, ensuring fast load times on both mobile and desktop. The following table summarizes the performance metrics:

MetricScoreNotes
Performance~100Optimized with Astro.js static rendering and React hydration
Accessibility~100Semantic HTML, ARIA attributes, and theme switching
SEO~100Metadata optimization and fast load times boost search rankings
Best Practices~100Secure headers, modern APIs, and TypeScript ensure code quality

Responsive Design with Tailwind CSS

Tailwind CSS was used to create a responsive, visually consistent design, supporting Bobologia’s light/dark mode feature. For example:

function TherapistCard({ therapist }) {
  return (
    <div className="bg-white dark:bg-gray-800 shadow-md rounded-lg p-4">
      <h2 className="text-xl font-bold text-gray-900 dark:text-white">{therapist.name}</h2>
      <p className="text-gray-600 dark:text-gray-300">{therapist.specialty}</p>
    </div>
  );
}

Tailwind’s utility-first approach simplifies styling and ensures seamless theme transitions.

Impact and Achievements

  • Client Growth: Since its launch on August 4, 2025, Bobologia’s optimized SEO has significantly increased new client appointments, with improved search rankings for therapy-related keywords.
  • Performance Excellence: Near-perfect Lighthouse scores ensure a fast, accessible, and SEO-friendly platform, enhancing user trust and engagement.
  • User-Centric Features: Features like automatic light/dark mode and responsive design have received positive feedback for improving accessibility and usability.
  • Scalable Architecture: The combination of React.js and Astro.js creates a maintainable, scalable codebase, ready for future enhancements.

Conclusion

Bobologia stands as a testament to the power of modern React.js best practices, from function components and custom hooks to TypeScript and Tailwind CSS. By integrating Astro.js, the platform achieves exceptional performance, accessibility, and SEO, delivering measurable business impact for Marta Konarzewska’s therapy practice. This project highlights the ability to build high-quality, user-focused web solutions, making it a standout addition to any full-stack developer’s portfolio. For developers looking to create similar platforms, these techniques offer a blueprint for success.

Citations:

More in FrontEnd