When using the native-desktop Core Library, it is important to verify whether your application is running inside the native-desktop environment or a regular web browser. The library’s features only work when the application is running inside Native Desktop.
You can perform this check using the isInNativeDesktop() function. For example:
import { isInNativeDesktop } from '@native-desktop/core';
const sampleFunction = () => {
const inNativeDesktop = isInNativeDesktop();
if (inNativeDesktop) {
// Execute Native Desktop-specific code here
}
}
Performing this check is necessary to prevent unexpected errors when the application runs in a normal browser.
If you are using frameworks like Next.js, the Core Library only works on the client side. You must add use client at the top of your page. Server-side rendered pages cannot access the Native Desktop Core Library.