T

Tagtics

概要

  • はじめに
  • 機能
  • 技術スタック

実装ガイド

  • クライアント概要
  • React / Next.js
  • Vue 3
  • Angular
  • Svelte
  • Solid.js
  • Vanilla JS / HTML
ドキュメント
アプリに戻る
実装ガイドReact / Next.js
実装ガイド

React / Next.js 統合

モダンなライフサイクルフックでTagticsを統合します。クライアントがルート変更を自動で処理します。

初期化

アプリのマウント時に init を、アンマウント時に destroy を呼び出してメモリリークを防ぎます。

import { useEffect } from 'react';

function App() {
  useEffect(() => {
    const script = document.createElement('script');
    script.src = 'https://cdn.tagtics.online/client.js';
    script.async = true;
    script.onload = () => {
      window.Tagtics?.init({ apiKey: 'YOUR_API_KEY' });
    };
    document.body.appendChild(script);

    return () => {
      window.Tagtics?.destroy();
      script.remove();
    };
  }, []);

  return <YourApp />;
}