I have defined the selectedCategory in page.tsx. I want then to send to retrieve/import selectedCategory in the file route.ts, but it always ends up being empty.
Since page.tsx is what is rendered for the user, I have also tried to fetch selectedCategory using useEffect and useState, but it does not seem to work.
Anyone can help?
page.tsx
"use client";
import React from "react";
import styles from "./page.module.css"; // use simple styles for demonstration purposes
import Chat from "../../components/chat";
const selectedCategory = "category1";
console.log("Selected category is: ", selectedCategory);
const Home = () => {
return (
<main className={styles.main}>
<div className={styles.container}>
<Chat />
</div>
</main>
);
};
export default Home;
export { selectedCategory };
route.ts (only relevant code rendered)
import { openai } from "@/app/openai";
import { selectedCategory } from "@/app/examples/first-chat/page";
console.log(selectedCategory)