Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
27d9a35
remix over next
adhami3310 Mar 18, 2025
764d013
make 404 page work
adhami3310 Mar 19, 2025
a04fa4b
Merge branch 'main' into remix-over-next
adhami3310 Mar 19, 2025
0ea874b
get layout working again
adhami3310 Mar 19, 2025
7d26ba7
in theory, one can get rid of jsx, but that would be craaazy
adhami3310 Mar 19, 2025
589a2a4
Fix aria-* and other hiphenated props in `jsx` mode
masenf Mar 20, 2025
462e734
compiler: preserve `app/routes.js` when purging
masenf Mar 20, 2025
6e5efff
remove next/link stuff from `rx.link`
masenf Mar 20, 2025
7826c6c
Merge branch 'main' into remix-over-next
adhami3310 Mar 20, 2025
19d97b8
completely remove jsx files and replace them with js files
adhami3310 Mar 20, 2025
9282eb9
fix special props handling
adhami3310 Mar 20, 2025
55af35a
fix empty name
adhami3310 Mar 20, 2025
cafb163
fix reflex web syntax error
adhami3310 Mar 20, 2025
9e460ce
Merge branch 'main' into remix-over-next
adhami3310 Mar 21, 2025
b06ea3b
fix dynamic rendering
adhami3310 Mar 21, 2025
5d42c71
bring helmet to fix issues with head in component, bonus fix for next…
adhami3310 Mar 21, 2025
4b7f5f9
got distracted
adhami3310 Mar 21, 2025
34f6185
Merge branch 'main' into remix-over-next
adhami3310 Mar 22, 2025
cf5657f
oh well
adhami3310 Mar 22, 2025
30f49f7
add helmet pyi
adhami3310 Mar 22, 2025
1c908c2
change vite config to fix builds
adhami3310 Mar 23, 2025
7a1ad50
one should format their js files, prettier said
adhami3310 Mar 23, 2025
b3b953d
precommit
adhami3310 Mar 23, 2025
da97dc2
try to optimize jsx import
adhami3310 Mar 23, 2025
760f85e
i don't know what i'm doing here
adhami3310 Mar 23, 2025
fc5d3f7
do this until we figure out how to fix that issue
adhami3310 Mar 23, 2025
a22b45a
ssr back to false
adhami3310 Mar 24, 2025
5f98c26
fix static directory name
adhami3310 Mar 24, 2025
89892ea
Merge branch 'main' into remix-over-next
adhami3310 Mar 29, 2025
3e78d27
merge changes
adhami3310 Mar 29, 2025
9a08ead
Merge branch 'main' into remix-over-next
adhami3310 Apr 11, 2025
09d5092
pyi
adhami3310 Apr 11, 2025
31382f2
update versions
adhami3310 Apr 11, 2025
c6874c1
Merge branch 'main' into remix-over-next
adhami3310 May 7, 2025
4456aca
use unstable_optimizeDeps
adhami3310 May 7, 2025
fe748d3
reset testing py
adhami3310 May 7, 2025
4e0899e
remove helmet pyi and make the tests wait for token
adhami3310 May 7, 2025
ef0120b
please
adhami3310 May 7, 2025
08ccedb
add timeout and log
adhami3310 May 7, 2025
fc213b3
add logs for polling
adhami3310 May 7, 2025
22fc252
add logs for starting backend
adhami3310 May 7, 2025
969a24e
python buffered
adhami3310 May 7, 2025
59f9a1b
require node 20
adhami3310 May 7, 2025
37e11a2
add logs for line
adhami3310 May 7, 2025
04ffac3
repr the line
adhami3310 May 7, 2025
27291e1
remove ansi
adhami3310 May 7, 2025
9bd79fe
remove -s
adhami3310 May 7, 2025
1a93060
brings back s for some time
adhami3310 May 7, 2025
b186413
maybe
adhami3310 May 7, 2025
ee14fb7
no color
adhami3310 May 7, 2025
ca817e1
remove -s now?
adhami3310 May 7, 2025
6988f4f
fix redirects
adhami3310 May 7, 2025
ce7c597
maybe ? i'm not sure
adhami3310 May 7, 2025
05b7e4e
move some of the config
adhami3310 May 7, 2025
2c51da2
make unit test cases pass
adhami3310 May 7, 2025
62e2037
fix the checkpoints for react router
adhami3310 May 7, 2025
acbe19b
do some stuff with the url
adhami3310 May 7, 2025
281cf25
fix client storage
adhami3310 May 8, 2025
612a9d6
yea that guy isn't happy
adhami3310 May 8, 2025
bfa85de
fix for react moment
adhami3310 May 8, 2025
1209e12
fix three tests
adhami3310 May 8, 2025
36665c1
try stuff with prerender
adhami3310 May 8, 2025
572f0ed
make it only on export
adhami3310 May 8, 2025
fcb67fb
fix lazy components
adhami3310 May 8, 2025
b433f21
prerender fix units
adhami3310 May 8, 2025
2e77cbc
i couldn't get this guy to work but at least make some progress
adhami3310 May 8, 2025
5d9ebc2
fix tailwind test
adhami3310 May 8, 2025
2b7ea03
fix test_event_actions
adhami3310 May 9, 2025
f425866
this shit is weird
adhami3310 May 9, 2025
9d49c1f
simplify things further
adhami3310 May 9, 2025
f72b51d
precommit
adhami3310 May 9, 2025
78154da
remove /
adhami3310 May 9, 2025
6a67ed2
fix datetime
adhami3310 May 9, 2025
0437a0c
make some progress on test dynamic route
adhami3310 May 9, 2025
1ca6077
remove work that wouldn't work
adhami3310 May 9, 2025
6bf150d
precommit
adhami3310 May 9, 2025
0c8c6ae
dynamic icon fix
adhami3310 May 9, 2025
6fb0f3e
Merge branch 'main' into remix-over-next
adhami3310 May 13, 2025
6a4221b
merge
adhami3310 May 13, 2025
4bdcbec
precommit
adhami3310 May 13, 2025
343971f
bring back some notion of link
adhami3310 May 13, 2025
3c76cf0
remove weird component
adhami3310 May 13, 2025
e3d6bd3
fix dynamic route
adhami3310 May 14, 2025
bf6e2ee
app
adhami3310 May 14, 2025
2fb69b3
Merge branch 'main' into remix-over-next
adhami3310 May 23, 2025
8bfe880
update tailwind plugins
adhami3310 May 23, 2025
ac7d311
update pyi hashes
adhami3310 May 23, 2025
8310443
precommit
adhami3310 May 23, 2025
2f300d1
remove helmet
adhami3310 May 23, 2025
1fc0d28
fix tests
adhami3310 May 23, 2025
29e598e
fix config for esm
adhami3310 May 24, 2025
7dfaa39
Revert "remove helmet"
adhami3310 May 24, 2025
4084e8f
bring back helmet but only for scripts
adhami3310 May 24, 2025
432673f
upgrade react
adhami3310 May 24, 2025
c8fa9db
Merge branch 'main' into remix-over-next
adhami3310 May 29, 2025
109cad2
fix cls
adhami3310 May 29, 2025
8ef294c
Merge remote-tracking branch 'origin/main' into remix-over-next
adhami3310 Jun 6, 2025
e015bcf
Merge remote-tracking branch 'origin/main' into remix-over-next
adhami3310 Jun 10, 2025
b48da69
use rolldown
adhami3310 Jun 11, 2025
bd3a95c
Merge remote-tracking branch 'origin/main' into remix-over-next
adhami3310 Jun 11, 2025
03d5939
add sitemap
adhami3310 Jun 11, 2025
005ccdd
add deploy url handling
adhami3310 Jun 11, 2025
b8c02fa
make native plugin only run on build
adhami3310 Jun 11, 2025
bc1112a
remove enableNativePlugin for now
adhami3310 Jun 11, 2025
9320220
remove setup frontend test
adhami3310 Jun 11, 2025
e9087f9
always have --bun ?
adhami3310 Jun 11, 2025
0c5efbb
maybe
adhami3310 Jun 11, 2025
45c2c2d
ok we can't get around that
adhami3310 Jun 11, 2025
bf7d521
we could do this though
adhami3310 Jun 11, 2025
99154af
Merge remote-tracking branch 'origin/main' into remix-over-next
adhami3310 Jun 11, 2025
bcf5f86
fix pyi
adhami3310 Jun 11, 2025
aa563ea
Match static route before dynamic route for on_load
masenf Jun 11, 2025
c182171
enable sitemap plugin
adhami3310 Jun 11, 2025
9d9f66d
Merge remote-tracking branch 'origin/main' into remix-over-next
adhami3310 Jun 11, 2025
bad3cb6
fix tailwind
adhami3310 Jun 11, 2025
a9ae165
also set inline colorScheme when the theme changes
masenf Jun 12, 2025
058f337
upgrade RR
adhami3310 Jun 13, 2025
cbb7fab
handle preset
adhami3310 Jun 13, 2025
eae0558
removed unused ignore
adhami3310 Jun 13, 2025
32ec255
fix build time and checkpoints
adhami3310 Jun 13, 2025
4f25ef2
Merge remote-tracking branch 'origin/main' into remix-over-next
adhami3310 Jun 13, 2025
b08f02c
make frontend listening regex handle dev and prod
adhami3310 Jun 13, 2025
ac5793b
[ENG-6295] missing stylesheet issue (#5446)
masenf Jun 13, 2025
f05685f
add fix for strict mode being there all the time
adhami3310 Jun 13, 2025
058dc60
prerender routes on prod mode (#5447)
adhami3310 Jun 13, 2025
5808f51
[ENG-6294] fix test_event_actions for react-router
masenf Jun 13, 2025
c0d456b
assert children
adhami3310 Jun 13, 2025
b004062
debounce input is default
adhami3310 Jun 13, 2025
3514c98
grid into no ssr
adhami3310 Jun 13, 2025
5b53faf
pyi
adhami3310 Jun 13, 2025
3f877f4
[ENG-6292] add explicit on_mount StrictMode test cases
masenf Jun 13, 2025
b795f12
optimize REACT_ROUTER_LINK_PROPS check
adhami3310 Jun 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/setup_build_env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ runs:
prune-cache: false
activate-environment: true
cache-dependency-glob: "uv.lock"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install Dependencies
if: inputs.run-uv-sync == 'true'
run: uv sync
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/integration_app_harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- "**/*.md"
env:
APP_HARNESS_HEADLESS: 1
PYTHONUNBUFFERED: 1

permissions:
contents: read
Expand Down
23 changes: 10 additions & 13 deletions pyi_hashes.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"reflex/__init__.pyi": "3afc0049639ae1663f916dd91e653dfe",
"reflex/components/__init__.pyi": "f3a4ccd8979222bdad1b8649f6734a6d",
"reflex/components/base/__init__.pyi": "e9aaf47be1e1977eacee97b880c8f7de",
"reflex/__init__.pyi": "0ca4974ab0fc44525e061ad39dd338fa",
"reflex/components/__init__.pyi": "f424d22ce0caa9375180195c273eb59c",
"reflex/components/base/__init__.pyi": "74d7764e03837231ea40a06dff08f44a",
"reflex/components/base/app_wrap.pyi": "5c2daf49c552c40d1247d998e200d01c",
"reflex/components/base/body.pyi": "b1df93ecdea60baf1495ef52aa742f31",
"reflex/components/base/document.pyi": "018f0207324a9cd4bac6d209fe3ae324",
"reflex/components/base/document.pyi": "f6e2dc26993b5481008da554356c6009",
"reflex/components/base/error_boundary.pyi": "42779d76ea6bc2847a33533cdac23f21",
"reflex/components/base/fragment.pyi": "b77ee8f55c73f45abf515ddbeb29c594",
"reflex/components/base/head.pyi": "31debbe85c37c40d8166504de121f905",
"reflex/components/base/link.pyi": "1cdc04cf0fbb2e2ed73feeb67aa55729",
"reflex/components/base/meta.pyi": "cdfb479b6140d5768285dfa7713774da",
"reflex/components/base/script.pyi": "29fcfe9d4655bdc020362eb780d0fa46",
"reflex/components/base/script.pyi": "eff80f98522bb4629bac5b55546bbeb2",
"reflex/components/base/strict_mode.pyi": "1d05089b3f201d3fcccde3a62a854d34",
"reflex/components/core/__init__.pyi": "44bcee7bc4e27e2f4f4707b843acf291",
"reflex/components/core/__init__.pyi": "d99fbfd4207d8a3f7013221f428e0ed8",
"reflex/components/core/auto_scroll.pyi": "fd6e78c419cd4b5ce77512f95603f9c9",
"reflex/components/core/banner.pyi": "75f64f49f7f1157f01f1e003737d2eda",
"reflex/components/core/client_side_routing.pyi": "c961a842715a99468110784224140c2c",
"reflex/components/core/client_side_routing.pyi": "df659032437ba52bbb94303fa54e1a46",
"reflex/components/core/clipboard.pyi": "e009ca6d0be9127d8acafbe959334ada",
"reflex/components/core/debounce.pyi": "72852ec7c60742122689b3c90740d276",
"reflex/components/core/helmet.pyi": "499a351957d7ef03c6b29bbbff699dce",
"reflex/components/core/html.pyi": "41c22b41433ec50ba9e07de813b764e6",
"reflex/components/core/sticky.pyi": "66c4ce29e7f9419bbb2101278973c0e0",
"reflex/components/core/upload.pyi": "90039579d573a7aa887d40889ced6154",
Expand All @@ -38,13 +38,10 @@
"reflex/components/el/elements/sectioning.pyi": "029b957c3da82d747a297811e9d71a43",
"reflex/components/el/elements/tables.pyi": "60ce25fd601003dfadd78d3081b86795",
"reflex/components/el/elements/typography.pyi": "3c4d82d4c61c84af85023d180631b081",
"reflex/components/gridjs/datatable.pyi": "963021af448b5f22960d521107194a87",
"reflex/components/gridjs/datatable.pyi": "1b8232fd3e839c6ae772db3d211cd632",
"reflex/components/lucide/icon.pyi": "b544769b37f1155ce97a170a21d1bcad",
"reflex/components/markdown/markdown.pyi": "3c818ed8f3a99edcba66ff00ec313f13",
"reflex/components/moment/moment.pyi": "77e40c9afd511fb046134e2581d8a3bd",
"reflex/components/next/base.pyi": "d445d407bf74ef571712632f1fc24c31",
"reflex/components/next/image.pyi": "bca53a266ce8159cf0e8ff30c65cf913",
"reflex/components/next/link.pyi": "dfb53816a637fb81955b529e7824be47",
"reflex/components/plotly/plotly.pyi": "8362d4dd3d5c57af79a8bc8d2dbe82c9",
"reflex/components/radix/__init__.pyi": "8d586cbff1d7130d09476ac72ee73400",
"reflex/components/radix/primitives/__init__.pyi": "fe8715decf3e9ae471b56bba14e42cb3",
Expand Down Expand Up @@ -108,7 +105,7 @@
"reflex/components/radix/themes/typography/blockquote.pyi": "5ac7c554663caed708e1a41a183a9bcb",
"reflex/components/radix/themes/typography/code.pyi": "5cbff824db591c92bc207066f2c0004e",
"reflex/components/radix/themes/typography/heading.pyi": "bb34ff7af2491bd7c424d378940a58c5",
"reflex/components/radix/themes/typography/link.pyi": "330158527b84c9e72ee7abf95d1217d3",
"reflex/components/radix/themes/typography/link.pyi": "97073a20f49b809a2713f0496fd9225c",
"reflex/components/radix/themes/typography/text.pyi": "cf2896cf1503d8196c5ca5b06914245f",
"reflex/components/react_player/audio.pyi": "c6cadf0f3db3892a7cda64e5672f4465",
"reflex/components/react_player/react_player.pyi": "4f1fbff94bbe714e56697a1d0b462bef",
Expand Down
1 change: 1 addition & 0 deletions reflex/.templates/jinja/app/rxconfig.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import reflex as rx
config = rx.Config(
app_name="{{ app_name }}",
plugins=[
rx.plugins.SitemapPlugin(),
rx.plugins.TailwindV4Plugin(),
],
)
2 changes: 1 addition & 1 deletion reflex/.templates/jinja/web/package.json.jinja2
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "reflex",
"type": "module",
"scripts": {
"dev": "{{ scripts.dev }}",
"export": "{{ scripts.export }}",
"export-sitemap": "{{ scripts.export_sitemap }}",
"prod": "{{ scripts.prod }}"
},
"dependencies": {
Expand Down
26 changes: 16 additions & 10 deletions reflex/.templates/jinja/web/pages/_app.js.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import '$/styles/__reflex_global_styles.css'
{% endblock %}

{% block declaration %}
import { EventLoopProvider, StateProvider, defaultColorMode } from "$/utils/context.js";
import { ThemeProvider } from 'next-themes'
import { EventLoopProvider, StateProvider, defaultColorMode } from "$/utils/context";
import { ThemeProvider } from '$/utils/react-theme';
import { Layout as AppLayout } from './_document';
import { Outlet } from 'react-router';
{% for library_alias, library_path in window_libraries %}
import * as {{library_alias}} from "{{library_path}}";
{% endfor %}
Expand All @@ -26,8 +28,9 @@ function AppWrap({children}) {
)
}

export default function MyApp({ Component, pageProps }) {
React.useEffect(() => {

export function Layout({children}) {
React.useEffect(() => {
// Make contexts and state objects available globally for dynamic eval'd components
let windowImports = {
{% for library_alias, library_path in window_libraries %}
Expand All @@ -36,17 +39,20 @@ export default function MyApp({ Component, pageProps }) {
};
window["__reflex"] = windowImports;
}, []);
return (
jsx(ThemeProvider, {defaultTheme:defaultColorMode,attribute:"class"},

return jsx(AppLayout, {},
jsx(ThemeProvider, {defaultTheme: defaultColorMode, attribute: "class"},
jsx(StateProvider, {},
jsx(EventLoopProvider, {},
jsx(AppWrap, {},
jsx(Component, pageProps)
)
jsx(EventLoopProvider, {},
jsx(AppWrap, {}, children)
)
)
)
);
}

export default function App() {
return jsx(Outlet, {});
}

{% endblock %}
2 changes: 1 addition & 1 deletion reflex/.templates/jinja/web/pages/_document.js.jinja2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "web/pages/base_page.js.jinja2" %}

{% block export %}
export default function Document() {
export function Layout({children}) {
return (
{{utils.render(document)}}
)
Expand Down
1 change: 0 additions & 1 deletion reflex/.templates/jinja/web/pages/base_page.js.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% import 'web/pages/utils.js.jinja2' as utils %}
/** @jsxImportSource @emotion/react */

{% block early_imports %}
{% endblock %}
Expand Down
31 changes: 25 additions & 6 deletions reflex/.templates/jinja/web/utils/context.js.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createContext, useContext, useMemo, useReducer, useState, createElement } from "react"
import { applyDelta, Event, hydrateClientStorage, useEventLoop, refs } from "$/utils/state.js"
import { createContext, useContext, useMemo, useReducer, useState, createElement, useEffect } from "react"
import { applyDelta, Event, hydrateClientStorage, useEventLoop, refs } from "$/utils/state"
import { jsx } from "@emotion/react";

{% if initial_state %}
export const initialState = {{ initial_state|json_dumps }}
Expand Down Expand Up @@ -77,7 +78,21 @@ export function UploadFilesProvider({ children }) {
delete newFilesById[id]
return newFilesById
})
return createElement(UploadFilesContext, {value:[filesById, setFilesById]}, children);
return createElement(
UploadFilesContext.Provider,
{ value: [filesById, setFilesById] },
children
);
}

export function ClientSide(component) {
return ({ children, ...props }) => {
const [Component, setComponent] = useState(null);
useEffect(() => {
setComponent(component);
}, []);
return Component ? jsx(Component, props, children) : null;
};
}

export function EventLoopProvider({ children }) {
Expand All @@ -87,7 +102,11 @@ export function EventLoopProvider({ children }) {
initialEvents,
clientStorage,
)
return createElement(EventLoopContext, {value:[addEvents, connectErrors]}, children);
return createElement(
EventLoopContext.Provider,
{ value: [addEvents, connectErrors] },
children
);
}

export function StateProvider({ children }) {
Expand All @@ -106,7 +125,7 @@ export function StateProvider({ children }) {
{% for state_name in initial_state %}
createElement(StateContexts.{{state_name|var_name}},{value: {{state_name|var_name}}},
{% endfor %}
createElement(DispatchContext.Provider, {value: dispatchers}, children),
{% for state_name in initial_state|reverse %}){% endfor %}
createElement(DispatchContext, {value: dispatchers}, children)
{% for state_name in initial_state %}){% endfor %}
)
}
8 changes: 8 additions & 0 deletions reflex/.templates/web/app/entry.client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { startTransition } from "react";
import { hydrateRoot } from "react-dom/client";
import { HydratedRouter } from "react-router/dom";
import { createElement } from "react";

startTransition(() => {
hydrateRoot(document, createElement(HydratedRouter));
});
10 changes: 10 additions & 0 deletions reflex/.templates/web/app/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { route } from "@react-router/dev/routes";
import { flatRoutes } from "@react-router/fs-routes";

export default [
route("*", "routes/[404]_._index.js"),
route("404", "routes/[404]_._index.js", { id: "404" }),
...(await flatRoutes({
ignoredRouteFiles: ["routes/\\[404\\]_._index.js"],
})),
];
Original file line number Diff line number Diff line change
@@ -1,45 +1,19 @@
import { useTheme } from "next-themes";
import { useRef, useEffect, useState, createElement } from "react";
import { useTheme } from "$/utils/react-theme";
import { createElement } from "react";
import {
ColorModeContext,
defaultColorMode,
isDevMode,
lastCompiledTimeStamp,
} from "$/utils/context.js";
} from "$/utils/context";

export default function RadixThemesColorModeProvider({ children }) {
const { theme, resolvedTheme, setTheme } = useTheme();
const [rawColorMode, setRawColorMode] = useState(defaultColorMode);
const [resolvedColorMode, setResolvedColorMode] = useState(
defaultColorMode === "dark" ? "dark" : "light",
);
const firstUpdate = useRef(true);
useEffect(() => {
if (firstUpdate.current) {
firstUpdate.current = false;
setRawColorMode(theme);
setResolvedColorMode(resolvedTheme);
}
});

useEffect(() => {
if (isDevMode) {
const lastCompiledTimeInLocalStorage =
localStorage.getItem("last_compiled_time");
if (lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp) {
// on app startup, make sure the application color mode is persisted correctly.
setTheme(defaultColorMode);
localStorage.setItem("last_compiled_time", lastCompiledTimeStamp);
return;
}
}
setRawColorMode(theme);
setResolvedColorMode(resolvedTheme);
}, [theme, resolvedTheme]);

const toggleColorMode = () => {
setTheme(resolvedTheme === "light" ? "dark" : "light");
};

const setColorMode = (mode) => {
const allowedModes = ["light", "dark", "system"];
if (!allowedModes.includes(mode)) {
Expand All @@ -50,10 +24,16 @@ export default function RadixThemesColorModeProvider({ children }) {
}
setTheme(mode);
};

return createElement(
ColorModeContext,
ColorModeContext.Provider,
{
value: { rawColorMode, resolvedColorMode, toggleColorMode, setColorMode },
value: {
rawColorMode: theme,
resolvedColorMode: resolvedTheme,
toggleColorMode,
setColorMode,
},
},
children,
);
Expand Down
7 changes: 0 additions & 7 deletions reflex/.templates/web/next.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion reflex/.templates/web/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
plugins: {
"postcss-import": {},
autoprefixer: {},
Expand Down
6 changes: 6 additions & 0 deletions reflex/.templates/web/react-router.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
future: {
unstable_optimizeDeps: true,
},
ssr: false,
};
40 changes: 21 additions & 19 deletions reflex/.templates/web/utils/client_side_routing.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import { useEffect, useRef, useState } from "react";
import { useRouter } from "next/router";
import { useLocation, useNavigate } from "react-router-dom";

/**
* React hook for use in /404 page to enable client-side routing.
* React hook for use in NotFound page to enable client-side routing.
*
* Uses the next/router to redirect to the provided URL when loading
* the 404 page (for example as a fallback in static hosting situations).
* Uses React Router to redirect to the provided URL when loading
* the NotFound page (for example as a fallback in static hosting situations).
*
* @returns {boolean} routeNotFound - true if the current route is an actual 404
*/
export const useClientSideRouting = () => {
const [routeNotFound, setRouteNotFound] = useState(false);
const didRedirect = useRef(false);
const router = useRouter();
const location = useLocation();
const navigate = useNavigate();

useEffect(() => {
if (
router.isReady &&
!didRedirect.current // have not tried redirecting yet
) {
didRedirect.current = true; // never redirect twice to avoid "Hard Navigate" error
if (!didRedirect.current) {
// have not tried redirecting yet
didRedirect.current = true; // never redirect twice to avoid navigation loops

// attempt to redirect to the route in the browser address bar once
router
.replace({
pathname: window.location.pathname,
query: window.location.search.slice(1),
})
const path = window.location.pathname;
const search = window.location.search;

// Use navigate instead of replace
navigate(path + search, { replace: true })
.then(() => {
// Check if the current route is /404
if (router.pathname === "/404") {
// Check if we're still on a NotFound route
// Note: This depends on how your routes are set up
if (location.pathname === path) {
setRouteNotFound(true); // Mark as an actual 404
}
})
.catch((e) => {
.catch(() => {
setRouteNotFound(true); // navigation failed, so this is a real 404
});
}
}, [router.isReady]);
}, [location, navigate]);

// Return the reactive bool, to avoid flashing 404 page until we know for sure
// the route is not found.
Expand Down
Loading
Loading