import { captureException } from '@sentry/react' import { Analytics as VercelAnalytics } from '@vercel/analytics/react' import { nanoid } from 'nanoid' import { useEffect } from 'react' import { createRoot } from 'react-dom/client' import { HelmetProvider } from 'react-helmet-async' import { Outlet, Route, RouterProvider, createBrowserRouter, createRoutesFromElements, redirect, useRouteError, } from 'react-router-dom' import '../sentry.client.config' import '../styles/core.css' import { DefaultErrorFallback } from './components/DefaultErrorFallback/DefaultErrorFallback' import { ErrorPage } from './components/ErrorPage/ErrorPage' import { Head } from './components/Head/Head' const router = createBrowserRouter( createRoutesFromElements( } ErrorBoundary={() => { const error = useRouteError() useEffect(() => { captureException(error) }, [error]) return ( ) }} > }> import('./pages/root')} /> { const id = 'v2' + nanoid() return redirect(`/r/${id}`) }} /> { const id = 'v2' + nanoid() return redirect(`/r/${id}`) }} /> import('./pages/public-multiplayer')} /> import('./pages/history')} /> import('./pages/history-snapshot')} /> import('./pages/public-snapshot')} /> import('./pages/public-readonly')} /> import('./pages/not-found')} /> ) ) createRoot(document.getElementById('root')!).render( ) try { // we have a dummy service worker that unregisters itself immediately // this was needed to remove the service worker we used to have from the cache // we can remove this if we ever need a service worker again, or if enough time passes that // anybody returning to tldraw.com should not have a service worker running navigator.serviceWorker.register('/sw.js', { scope: '/', }) } catch (e) { // ignore }