Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Enable remix v3 feature flags

Blue Mouse612e67be0991
diff --git a/web/app/entry.server.tsx b/web/app/entry.server.tsx
index 6917e1c2b..3202cf9ec 100644
--- a/web/app/entry.server.tsx
+++ b/web/app/entry.server.tsx
@@ -14,7 +14,8 @@ import { MAIN_URL } from './lib/constants'
import i18next from './i18next.server'
import i18n, { detectLanguage } from './i18n'
-const ABORT_DELAY = 5_000
+// Reject/cancel all pending promises after 5 seconds
+const streamTimeout = 5000
const { isSitemapUrl, sitemap } = createSitemapGenerator({
siteUrl: MAIN_URL,
@@ -57,7 +58,7 @@ export default async function handleRequest(
const { pipe, abort } = renderToPipeableStream(
<I18nextProvider i18n={instance}>
- <RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />
+ <RemixServer context={remixContext} url={request.url} />
</I18nextProvider>,
{
[callbackName]: () => {
@@ -84,6 +85,8 @@ export default async function handleRequest(
},
)
- setTimeout(abort, ABORT_DELAY)
+ // Automatically timeout the React renderer after 6 seconds, which ensures
+ // React has enough time to flush down the rejected boundary contents
+ setTimeout(abort, streamTimeout + 1000)
})
}
diff --git a/web/app/root.tsx b/web/app/root.tsx
index 54b293272..0d8ff878d 100644
--- a/web/app/root.tsx
+++ b/web/app/root.tsx
@@ -1,6 +1,6 @@
/* eslint-disable no-undef */
import type { LinksFunction, LoaderFunctionArgs, HeadersFunction } from '@remix-run/node'
-import { json, redirect } from '@remix-run/node'
+import { data, redirect } from '@remix-run/node'
import { useState } from 'react'
import {
Links,
@@ -200,7 +200,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
: undefined
- return json(
+ return data(
{
locale,
url,
@@ -218,7 +218,7 @@ export const handle = {
}
export default function App() {
- const { locale, url, theme, REMIX_ENV, isAuthed } = useLoaderData<typeof loader>()
+ const { locale, url, theme, REMIX_ENV, isAuthed } = useLoaderData<any>()
const { i18n } = useTranslation('common')
const urlObject = new URL(url)
diff --git a/web/app/routes/$.tsx b/web/app/routes/$.tsx
index 82771ec59..bf1a7d9b7 100644
--- a/web/app/routes/$.tsx
+++ b/web/app/routes/$.tsx
@@ -1,6 +1,6 @@
import type { LoaderFunction } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
-import { json } from '@remix-run/node'
+import { data } from '@remix-run/node'
import NotFound from '~/pages/NotFound'
export const sitemap: SitemapFunction = () => ({
@@ -8,7 +8,7 @@ export const sitemap: SitemapFunction = () => ({
})
export const loader: LoaderFunction = () => {
- return json(null, { status: 404 })
+ return data(null, { status: 404 })
}
export default function Index() {
diff --git a/web/app/routes/billing.tsx b/web/app/routes/billing.tsx
index 28f0f19ac..1c2be658f 100644
--- a/web/app/routes/billing.tsx
+++ b/web/app/routes/billing.tsx
@@ -1,6 +1,6 @@
import type { LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
-import { json, redirect } from '@remix-run/node'
+import { data, redirect } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
import Billing from '~/pages/Billing'
@@ -19,11 +19,11 @@ export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
const isAuth = isAuthenticated(request)
- return json({ isAuth, theme })
+ return data({ isAuth, theme })
}
export default function Index() {
- const { isAuth, theme } = useLoaderData<typeof loader>()
+ const { isAuth, theme } = useLoaderData<any>()
return <Billing ssrAuthenticated={isAuth} ssrTheme={theme} />
}
diff --git a/web/app/routes/blog.$category.$slug.tsx b/web/app/routes/blog.$category.$slug.tsx
index 3bffe5843..2cfe94e12 100644
--- a/web/app/routes/blog.$category.$slug.tsx
+++ b/web/app/routes/blog.$category.$slug.tsx
@@ -1,5 +1,5 @@
import type { LoaderFunction, LinksFunction, MetaFunction } from '@remix-run/node'
-import { redirect, json } from '@remix-run/node'
+import { redirect, data } from '@remix-run/node'
import singlePostCss from '~/css/mdfile.css'
import { getPost } from '~/utils/getPosts'
import { isSelfhosted, TITLE_SUFFIX, getOgImageUrl } from '~/lib/constants'
@@ -55,7 +55,7 @@ export const loader: LoaderFunction = async ({ params }) => {
const { slug, category } = params
if (!slug || !category) {
- return json(null, {
+ return data(null, {
status: 404,
})
}
@@ -63,7 +63,7 @@ export const loader: LoaderFunction = async ({ params }) => {
const post = await getPost(slug, category)
if (!post) {
- return json(null, {
+ return data(null, {
status: 404,
})
}
diff --git a/web/app/routes/blog.$slug.tsx b/web/app/routes/blog.$slug.tsx
index 09ed7e42d..0407b509e 100644
--- a/web/app/routes/blog.$slug.tsx
+++ b/web/app/routes/blog.$slug.tsx
@@ -1,6 +1,6 @@
import type { SitemapFunction } from 'remix-sitemap'
import type { LoaderFunction, LinksFunction, MetaFunction } from '@remix-run/node'
-import { redirect, json } from '@remix-run/node'
+import { redirect, data } from '@remix-run/node'
import _map from 'lodash/map'
import _last from 'lodash/last'
import _join from 'lodash/join'
@@ -84,7 +84,7 @@ export const loader: LoaderFunction = async ({ params }) => {
}
if (!params.slug) {
- return json(null, {
+ return data(null, {
status: 404,
})
}
@@ -92,7 +92,7 @@ export const loader: LoaderFunction = async ({ params }) => {
const post = await getPost(params.slug)
if (!post) {
- return json(null, {
+ return data(null, {
status: 404,
})
}
diff --git a/web/app/routes/captchas.$id.tsx b/web/app/routes/captchas.$id.tsx
index f29871eb1..d26627f3c 100644
--- a/web/app/routes/captchas.$id.tsx
+++ b/web/app/routes/captchas.$id.tsx
@@ -1,5 +1,5 @@
import CaptchaView from '~/pages/Captcha/View'
-import { json, type LinksFunction, type LoaderFunctionArgs } from '@remix-run/node'
+import type { LinksFunction, LoaderFunctionArgs } from '@remix-run/node'
import ProjectViewStyle from '~/styles/ProjectViewStyle.css'
import { detectTheme } from '~/utils/server'
import { useLoaderData } from '@remix-run/react'
@@ -9,9 +9,9 @@ export const links: LinksFunction = () => [{ rel: 'stylesheet', href: ProjectVie
export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
- return json({
+ return {
theme,
- })
+ }
}
export default function Index() {
diff --git a/web/app/routes/error-tracking.tsx b/web/app/routes/error-tracking.tsx
index 9adfd1cb9..84d1fdec2 100644
--- a/web/app/routes/error-tracking.tsx
+++ b/web/app/routes/error-tracking.tsx
@@ -1,6 +1,6 @@
import type { LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
import ErrorTracking from '~/pages/ErrorTracking'
@@ -20,7 +20,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
const isAuth = isAuthenticated(request)
- return json({ theme, isAuth })
+ return { theme, isAuth }
}
export default function Index() {
diff --git a/web/app/routes/for-marketers.tsx b/web/app/routes/for-marketers.tsx
index 1d34f6483..496ad3af1 100644
--- a/web/app/routes/for-marketers.tsx
+++ b/web/app/routes/for-marketers.tsx
@@ -1,6 +1,6 @@
import Marketers from '~/pages/Landings/Marketers'
import type { LoaderFunctionArgs } from '@remix-run/node'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
import { detectTheme, isAuthenticated } from '~/utils/server'
@@ -18,7 +18,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const isAuth = isAuthenticated(request)
const [theme] = detectTheme(request)
- return json({ theme, isAuth })
+ return { theme, isAuth }
}
export default function Index() {
diff --git a/web/app/routes/for-small-businesses.tsx b/web/app/routes/for-small-businesses.tsx
index 8065358a4..007e1dda8 100644
--- a/web/app/routes/for-small-businesses.tsx
+++ b/web/app/routes/for-small-businesses.tsx
@@ -1,6 +1,6 @@
import SmallBusinesses from '~/pages/Landings/SmallBusinesses'
import type { LoaderFunctionArgs } from '@remix-run/node'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
import { detectTheme, isAuthenticated } from '~/utils/server'
@@ -18,7 +18,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const isAuth = isAuthenticated(request)
const [theme] = detectTheme(request)
- return json({ theme, isAuth })
+ return { theme, isAuth }
}
export default function Index() {
diff --git a/web/app/routes/for-startups.tsx b/web/app/routes/for-startups.tsx
index 02bac32d2..f54b66eed 100644
--- a/web/app/routes/for-startups.tsx
+++ b/web/app/routes/for-startups.tsx
@@ -1,6 +1,6 @@
import Startups from '~/pages/Landings/Startups'
import type { LoaderFunctionArgs } from '@remix-run/node'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
import { detectTheme, isAuthenticated } from '~/utils/server'
@@ -18,7 +18,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const isAuth = isAuthenticated(request)
const [theme] = detectTheme(request)
- return json({ theme, isAuth })
+ return { theme, isAuth }
}
export default function Index() {
diff --git a/web/app/routes/index.tsx b/web/app/routes/index.tsx
index 94f376940..d1772e261 100644
--- a/web/app/routes/index.tsx
+++ b/web/app/routes/index.tsx
@@ -1,6 +1,6 @@
import type { LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData, Link } from '@remix-run/react'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
import { UAParser } from 'ua-parser-js'
import { motion } from 'framer-motion'
@@ -74,7 +74,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
}
- return json({ theme, isAuth, deviceInfo })
+ return { theme, isAuth, deviceInfo }
}
const Problem = () => {
diff --git a/web/app/routes/login.tsx b/web/app/routes/login.tsx
index 539c2cbd9..f8a1f0203 100644
--- a/web/app/routes/login.tsx
+++ b/web/app/routes/login.tsx
@@ -1,7 +1,6 @@
import Signin from '~/pages/Auth/Signin'
import type { HeadersFunction, LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
-import { json } from '@remix-run/node'
import { detectTheme } from '~/utils/server'
@@ -13,7 +12,7 @@ export const headers: HeadersFunction = ({ parentHeaders }) => {
export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
- return json({ theme })
+ return { theme }
}
export default function Index() {
diff --git a/web/app/routes/performance.tsx b/web/app/routes/performance.tsx
index 8b968be72..44e225189 100644
--- a/web/app/routes/performance.tsx
+++ b/web/app/routes/performance.tsx
@@ -1,7 +1,7 @@
import Performance from '~/pages/Performance'
import type { LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
import { detectTheme, isAuthenticated } from '~/utils/server'
@@ -20,7 +20,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
const isAuth = isAuthenticated(request)
- return json({ theme, isAuth })
+ return { theme, isAuth }
}
export default function Index() {
diff --git a/web/app/routes/projects.$id.password.tsx b/web/app/routes/projects.$id.password.tsx
index 83b687e7e..f0af42489 100644
--- a/web/app/routes/projects.$id.password.tsx
+++ b/web/app/routes/projects.$id.password.tsx
@@ -1,7 +1,6 @@
import ProjectProtectedPassword from '~/pages/Project/ProjectProtectedPassword'
import type { LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
-import { json } from '@remix-run/node'
import { detectTheme, isEmbedded, getProjectPassword, isAuthenticated } from '~/utils/server'
@@ -11,12 +10,12 @@ export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
const isAuth = isAuthenticated(request)
- return json({
+ return {
theme,
embedded,
queryPassword,
isAuth,
- })
+ }
}
export default function Index() {
diff --git a/web/app/routes/projects.$id.tsx b/web/app/routes/projects.$id.tsx
index b0dbcdbc2..7b361e7a0 100644
--- a/web/app/routes/projects.$id.tsx
+++ b/web/app/routes/projects.$id.tsx
@@ -1,6 +1,5 @@
import ViewProject from '~/pages/Project/View'
import type { LinksFunction, LoaderFunctionArgs, MetaFunction } from '@remix-run/node'
-import { json } from '@remix-run/node'
import _split from 'lodash/split'
import { API_URL } from '~/lib/constants'
@@ -27,13 +26,13 @@ export async function loader({ request }: LoaderFunctionArgs) {
const isAuth = isAuthenticated(request)
const tabs = getProjectTabs(request)
- return json({
+ return {
theme,
embedded,
isAuth,
queryPassword,
tabs,
- })
+ }
}
export default function Index() {
diff --git a/web/app/routes/projects.settings.$id.tsx b/web/app/routes/projects.settings.$id.tsx
index df4fed302..3a28903bd 100644
--- a/web/app/routes/projects.settings.$id.tsx
+++ b/web/app/routes/projects.settings.$id.tsx
@@ -1,9 +1,8 @@
-import { json, type LoaderFunctionArgs } from '@remix-run/node'
+import type { LoaderFunctionArgs } from '@remix-run/node'
import ProjectSettings from '~/pages/Project/Settings'
export async function loader({ request }: LoaderFunctionArgs) {
- // return current domain origin, like https://app.swetrix.com
- return json({ requestOrigin: request.headers.get('origin') })
+ return { requestOrigin: request.headers.get('origin') }
}
export default function Index() {
diff --git a/web/app/routes/ref.$id.tsx b/web/app/routes/ref.$id.tsx
index c79d96d8d..a03711ab8 100644
--- a/web/app/routes/ref.$id.tsx
+++ b/web/app/routes/ref.$id.tsx
@@ -1,6 +1,6 @@
import type { LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import ReferralPage from '~/pages/ReferralPage'
import { isSelfhosted } from '~/lib/constants'
@@ -13,7 +13,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
- return json({ theme })
+ return { theme }
}
export default function Index() {
diff --git a/web/app/routes/signup.tsx b/web/app/routes/signup.tsx
index 8e417c83b..114bf24a3 100644
--- a/web/app/routes/signup.tsx
+++ b/web/app/routes/signup.tsx
@@ -2,7 +2,7 @@ import Singup from '~/pages/Auth/Signup'
import type { SitemapFunction } from 'remix-sitemap'
import type { HeadersFunction, LoaderFunctionArgs } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
-import { json, redirect } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import { isSelfhosted } from '~/lib/constants'
import { detectTheme } from '~/utils/server'
@@ -19,7 +19,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const [theme] = detectTheme(request)
- return json({ theme })
+ return { theme }
}
export const sitemap: SitemapFunction = () => ({
diff --git a/web/remix.config.js b/web/remix.config.js
index bfa9a791f..67062e026 100644
--- a/web/remix.config.js
+++ b/web/remix.config.js
@@ -25,7 +25,15 @@ module.exports = {
/^remix-utils.*/,
/^remix-i18next.*/,
],
+ // eslint-disable-next-line no-undef
serverMinify: process.env.NODE_ENV === 'production',
+ future: {
+ v3_fetcherPersist: true,
+ v3_throwAbortReason: true,
+ v3_lazyRouteDiscovery: true,
+ v3_singleFetch: true,
+ v3_relativeSplatPath: true,
+ },
routes(defineRoutes) {
// uses the v1 convention, works in v1.15+ and v2
return createRoutesFromFolders(defineRoutes)