Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React 19] - Server action console log renders in the browser console #32264

Open
ungureanustefan opened this issue Jan 29, 2025 · 4 comments
Open
Labels

Comments

@ungureanustefan
Copy link

ungureanustefan commented Jan 29, 2025

Quick question. I have just updated to React 19 and I am trying to make a request on a server action and hide it's functionality from the browser. So basically if I make an api call, or I simply console.log something, then that shouldn't be visible on the browser. So take the following code for example:

`'use server';
export async function deleteUser(){

	console.log('object');
};`

`export default function RouteErrorBoundary({ pageTitle }: { pageTitle: string }) {
const error = useRouteError();
const location = useLocation();

const errorString = JSON.stringify(error, Object.getOwnPropertyNames(error));
const descriptiveError = 'Found on page' + location.pathname + '; ' + 'Error: ' + errorString;
return (
	<BaseLayout title={pageTitle}>
		<PageMessage
			title="There has been an error on our side"
			text="This issue has been logged"
			icon={WarningIcon}
			background="transparent"
		/>
		<form action={deleteUser}>
			<button>Send</button>
		</form>
	</BaseLayout>
);

}
`

For whatever reason, I just can't make the console log appear just in VSCode. It still behaves as if I'm using a "client function". Can I achieve what I need?

@V3RON
Copy link
Contributor

V3RON commented Jan 30, 2025

Server functions require support from a bundler or framework. What is your setup?

@ungureanustefan
Copy link
Author

@V3RON I am using Vite and everything that comes with "npm create vite@latest" when creating a React + Typescript app.

@V3RON
Copy link
Contributor

V3RON commented Jan 30, 2025

@ungureanustefan That's the problem: Vite doesn't support React's server-side functionalities by default. I suggest trying out the new features in one of the recommended frameworks.
https://react.dev/learn/start-a-new-react-project#production-grade-react-frameworks

@ungureanustefan
Copy link
Author

@V3RON I don't think that's going to be possible though, because I wanted to implement these new server features of React 19 in the company's project that I'm working on. The project is too far ahead to be rewritten with Next.js now.

What I don't get is, Next.js already had these server features before React 19 was out for installing. So now that React 19 is out with the server features... it seems that they can't really be used if you don't use Next.js or any of the suggested frameworks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants