This is a simple React demo application that shows how to use the msnodesqlv8 native module in a React application running within Electron.
- Node.js
- ODBC Driver 18 for SQL Server
- A SQL Server instance running on
127.0.0.1:1433with:- Database:
node - User:
node_user - Password:
StrongPassword123!
- Database:
npm installThe postinstall script will automatically rebuild the msnodesqlv8 module for Electron.
To run the React app inside Electron where the native module will work:
# For development with hot reload
npm run electron-dev
# Or just run Electron
npm run electronnpm startNote: When running as a standalone React app in the browser, the msnodesqlv8 module won't be available since it's a native Node.js module. You'll see an error message in the UI.
To build the React app for production:
npm run buildThen run the built version in Electron:
npm run electron- The React app is built using Webpack with special configuration to handle native modules
- When running in Electron, the app has access to Node.js APIs including the msnodesqlv8 module
- The app connects to SQL Server and runs a simple query when you click the button
- Results are displayed in the UI
If you encounter issues with the native module:
- Make sure you have the correct ODBC drivers installed
- Rebuild the native module:
npm run electron-rebuild - Ensure your SQL Server connection string is correct
- Check that SQL Server is running and accessible