{"id":1121,"date":"2022-08-09T11:01:30","date_gmt":"2022-08-09T11:01:30","guid":{"rendered":"https:\/\/www.workfall.com\/learning\/blog\/?p=1121"},"modified":"2025-09-30T05:01:40","modified_gmt":"2025-09-30T05:01:40","slug":"how-to-show-flash-messages-in-node-js-using-the-connect-flash-package","status":"publish","type":"post","link":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/","title":{"rendered":"How to Show Flash Messages in Node.js using the Connect-flash Package?"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">7<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p><img src=\"https:\/\/lh4.googleusercontent.com\/KvG6J7XYfjeFwg6uyZK_ZQuScYWGyNhMKCfCE9o9rUoJIwcRmf7Cx3aoSQ5lNdSmoQQGw5TOu7Q5uBMdlaqvFXf9QmUP-tef-uWyux0hWffh7oLXh2H3QlarxCBdys11bBOmwXL2UrfmZTvAFu0CM80\" style=\"width: 1600px;\"><\/p>\n\n\n\n<p class=\"has-text-align-justify\">The <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-export-data-to-a-csv-file-using-multiple-npm-packages-in-node-js\/\">Node.js<\/a> Connect-flash module is extremely useful for developers whenever a flash message needs to be sent. When a user is redirected to a specific webpage, the connect-flash module in Node.js allows developers to display a pop-up message. For example, in your Node.js demo application, you might want to notify your users when they log in and out. You can accomplish this by utilizing the connect-flash module in your Node.js app.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Flash is a session-specific area used to store messages. Messages are written to the flash and then cleared after the user sees them. Flash is commonly used in conjunction with redirects to ensure that the message is available on the next page to be rendered.<\/p>\n\n\n\n<p>To know more about Node.js &amp; Npm, refer to: <\/p>\n\n\n\n<p><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-export-data-to-a-csv-file-using-multiple-npm-packages-in-node-js\/\">How To Export Data To A CSV File Using Multiple Npm Packages In Node.Js?<\/a><\/p>\n\n\n\n<h2>Hands-on<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this hands-on, we will have a look at how we can display flash messages on a webpage whenever needed (ie. Based on displaying a success or failure message pop-up to a user). To do so, we will first begin with creating the package.json file and installing the required packages for successful results. Verifying the package installations, we will then proceed further and import the packages into our codebase. Then we will define a port number where our application will run and we will create a session secret to encrypt any personal information. Followed by that, we will define the routes as to where the message is to be displayed on hitting a specific URL. Testing out the same, we will install the ejs view engine, create a template, beautify the message display file, alter the main codebase to accommodate the same, and finally restart the server and test out the execution.<\/p>\n\n\n\n<h3>Required installations for the process:<\/h3>\n\n\n\n<ul><li><strong>Node.js: <\/strong>It is a JavaScript runtime environment that executes JavaScript code outside the browsers.<\/li><li><strong>Connect-flash: <\/strong>The following package allows users to display a pop-up message whenever a user is directed to a specific page on an application.<\/li><li><strong>Express: <\/strong>It is a Node.js framework required for the execution of the package connect-flash.<\/li><li><strong>Express-session: <\/strong>It is used to create a session whenever a message is flashed.<\/li><li><strong>ejs: <\/strong>It is a template language that allows us to create HTML pages using Javascript.<\/li><\/ul>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Note:<\/strong> Please ensure that Node.js is properly installed onto the local machine or else it might display multiple errors while following the process.<\/p>\n\n\n\n<p>Create a new directory on your local machine.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/Z66x499gr6k6MyfcZc8XOou79i5Ywa1HrrLvT2ZcdkS2jNkrVTvrVdUGCGK9PPrVZf9g0WZ2Xb-HEM-OPYXnM6IUxFSOOkcTbakD_5NkZ4xmJ5pS8QUf_RkQSofW9XLQBldDw1V_QydDOrOmlrgI1G0\" alt=\"\"\/><\/figure>\n\n\n\n<p>Open the newly created directory into a code editor.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/ZPHKBbCiWD0FqH_RmB24RKtIorAXsqDKOXzCua0nwUuPboDrQGBOl4ZZVsrYg5UXDACGBGKIqimWYbsKf6Xqgj80-_CRDHCq1s5EE_9p-phHdYFyRk0ElysxUkhgG8xsbmpn04upSJg7hLu8XHkt4nU\" alt=\"\"\/><\/figure>\n\n\n\n<p>Right-click in the left navigation pane and click on New file.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/eIctVCtr0lZ4m47Mbs996Ni2dXzQS6o0koXBr_ZSF-a6WXUKSkhgrTEoyhzUCllkXkCIUBygOeOY-jS-F0W-TsDtQM9WDqdyjisMdjHwVO4u_9N5zGtL8XEZRU0s0FuK7DaZk2tfOfyinB8BK5b_uHU\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a new file with the name package.json.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/aqMjuaJEuqzREEoYNilokOY3DYQH-9D4X751iZp3I6aEzW1ryQ6XegcFTY6CGUvyl5jYFLH9aBTV7MbgNvlm2An-A1cwviYjMn6EOmgyTqFWEOnirJuVnwp4Mz4Xz7nOgAQX3HKv1LgypD7XUjKCgm0\" alt=\"\"\/><\/figure>\n\n\n\n<p>Right-click in the newly created directory and click on Git Bash Here.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/IWpCfuWDO4r9AtlyBqFnNgH-Djc54vHkAMqiDCgxHnrFTrwepZPxC8DaT4S16AYvLL_Or7uZ6AeWYQIaTACIFR5yRdtCWBXwNrVK75J8YtiKzCByl_fYZcRYB_6GW3quUqsXNdHG54QyZXCkuJYfTu8\" alt=\"\"\/><\/figure>\n\n\n\n<p>Run the command: <code>npm init<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/qzn11estV8dSewK1ycADqy-FmfL4B0SgKzwH2qMywwcc_7c7-iZ4qM7Fio6tBYughoi3aNa1RGnNZGGJ_eaoF1u3YcXIOG0nMfnobjvkS9DG_mkEbrUr9tiKZC1oIbULWZ7aXJutb0xQTWixxlbabG8\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Press yes after selecting the default values.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/49tzvSBTAQkK4el2SKQCNLTEGVwPvYQWDahxhsPf_wHi19axnzczbczvJSxKfO-KILutwdqPxv6lxw7QX4uw49dAVTZvSqaAkLXSDt7NDUCen-9S_w1-jAlpM74L4kX2vob8w0mFUCNsEQqNe_ALcb8\" alt=\"\"\/><\/figure>\n\n\n\n<p>Verify the configuration setup in the package.json file created above.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/cM0WHWa_Uq1Rt1MRYG1ft-bwpleSNNPwYZjlqcCnxpBxXJX47VLYsUbWTPmY7fqhkBSDqBD7KmGo6AZ1LneJ_zR0PgkSiMaVxyvGYkT5qBIkRR-6dvpI50CxrySPfGu2fpXdG0H0S4FzD_safXHJ_CY\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>To implement flash messages, we need to install the following dependencies as we discussed above.<\/p>\n\n\n\n<p>Run the command: <code>npm install connect-flash express express-session --save<\/code><\/p>\n\n\n\n<p>This command will install the connect-flash package, express, and express-session.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/gHA7P3IVfSzaxNkMYWpUSeIer_DaCitjXW4Mnspj3Nktw29UKYN-c_gkorcuFWi8svLUo4Oe_GXyMw4TieCNAK8AO9tfbik5Ov2kham6GTQNps0JfD6eNOyYwHv9VozKJBEY89TcXdoPp67pPM_tLsU\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Verify the package installations by navigating to the package.json file.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/EO65fm2FZ73cjBWTNj31LseDTws-wFvXROJSVxzv9ZLze47FC5905EyOdwOumKXUzfp2Qx-l2Zn_VDKnFPMoUJ9rZ95DRSv6HogrV8nLqqBmUNTV1jysPisuwEp-9VDYpfRdpZ_z34xqiTpJKwkfW-s\" alt=\"\"\/><\/figure>\n\n\n\n<p>A new package-lock.json file will be created in the directory.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/4dEdH7u8sNpoXLpqZ6mF3XKTetB0LiVrUrau_iZq8-Z_kVoatrPsWzW7GtvTn-v7Co1t1IspWdpEo2f5vmHfjAgKFzJ1Veht0WmESEHDesn4VUVGjJPvWQHytYQHS413Y7PnnHR7rs0c77iNPrRAogo\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a new file with the name index.js.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/44kK6yNzAceCz7DryOgNLAiGfG9MIMZuj1-bn7nETbwguY0TRhAZULqsllADjtQW0fNceYcbzFqJai9EhxWnm2LeKFXKK9LBSGfI4db2X8_ux6L1nepi7di6WY71h9aBDnSDaGjxXcG5RS9S-6TJ2k4\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>In the index.js file, import the installed packages using the code below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/9Du5unQkGVCp1q2JApdX9Qb_oj28qzGG6v0GYMD2CbVhZXD5ghMm_rZXuESiSbKZAq7IMM5SC7zlbUgOGMLMnnH2mUk0Ciyutg_1Sx6d-pE0THQiv21BirYR2llzn0wByAl5jwH36KJb1mvsCOpKlF8\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Define a port number using the below code on which our application will run.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/bw_VkxV46OIV4scqPzuB4trvLNcvn2NtNIlFMSXPFoROtFWVwMPsdLn_XAJahBD22i-cpKHIB2V85yG1By9acaYPuCelwO1gv2tw0OF0J2Ks50mM2Lp5I9DfkGKeUn0aUOacLn5heQ41vPsBaSNmBd8\" alt=\"\"\/><\/figure>\n\n\n\n<p>We will then define a session secret encrypting any information using the below code. Using the last line, we will call the connect-flash module.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/WGY5_Uhd0ivSVWFXukX1qCXWleWZnPDCu8xpda2TX89j-wwCwu_rTqhiuSzHgaM3C0TnX7lvQPzzDx8d9bDragIs-w4GwVf93NesQwnB59-fp84Wi9OWdoBiI0QTdeMUCJch_QHS53c4u_hhnwdgvFM\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>We will use the below path for displaying the specified message thereby redirecting the user to the \/flash-message path.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/QsCBT4N_C2c-QSiPzBKeb3ZMP08CRj2wfSVQWG_SXR4QTLfVD0SmP58GEhwQDVn2-w3J7cS9LZvsT8tMsm_TbzNZpHNQLnGst1Gm4iQ_3KXFgD6k-QSoxAxSqAWvEr6S8vJx_3QmRdibKwhp0V54K6w\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>The following path will be used for displaying the specific message on the web page.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/Lltf2BYsf1iJmocdIKpaJsY4BBMbyU335wpMiGmmovIUQh_MM90F74aRh00il7i_FEmtWWoDtDUk0Ct-TXHZ2Zk42kAoB-rIvGcyRd5EdfY1jhEVteavBva8r9DUvK1SihPLQBntLY5Mt0c4PO9ia3s\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>After adding and combining the entire code set, the combined code looks like as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/hqEqORyKQohgu0IG90CUPaEJeLcflZPAgu7g5k-ui_UNfDtkwcm5km6uALOC7F64PErDnpRPefDcQdaN5I1fiiGMjY86bv8mrWpEnvwDguyfHRIiYQtWS4boafgSrZ1IcKxFkZkev4UyG_rpocYZLbs\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Now, run node index.js in cmd to start the server.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/7TVnOtaTfWfoykwdvgevZD4rpq_8hzTca0ijMpE5Js8m1omoPkbyW_PWnHOLWCPQb-A0fAPbPIvUks6jwJNtHVZAC8jziOMRzb3ksRwowGl3hfYtbmBw949O8sAXbmPblVh9d9gEXBf9GbHVdgJBd3g\" alt=\"\"\/><\/figure>\n\n\n\n<p>Hit the following path on any of the browsers.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ne8nEAKuDIueGYnO6FyCtE7_sKwpxbZObdMZuiroXaZ5QWQ7KRR6zuEL2bqDWSS6GBGmFBO7aQFrJq8mpAwygxmykFJKnB3WpwSB4T3CMy4un8j1izpAwkfKk3D2WXwznDO5bOepK7DD5_RSZmpf6LM\" alt=\"\"\/><\/figure>\n\n\n\n<p>On successful execution of the code, you will see the message on the screen as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/HY_GdkTnoWNSNg-Rqd7EZEc8LPVLQ8fSkrVT5W86zYgcIEJuFuJUedrJO4ouKg1QuPqDffdreWasIfL59npnMgH7ZE0rVJIkP65yK-fFfvEM9RMu2lq8LbRJBS2sNaLPvWeM7TytZa2nGpkKeL8_kws\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Now we will display the flash messages using the view file.&nbsp;<\/p>\n\n\n\n<p>Run the following command to install the ejs view engine.&nbsp;<\/p>\n\n\n\n<p><code>npm install ejs<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/2pSCysJPhkOU4UYOMNK4MbNH6xwvfyd1tgR1GICjuX7AgZvCUrXoL6ZjysZhs07VwKigR07Hr0Szq_TXg98USuXGZYf7WI25NM3_X58yjRmCdAej-az_cvwbVzEkRcmTTmJoGKald9hfH0aFHyeZIcQ\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Open the index.js file and add the below code in the same file.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/U7zwiu4WqP5MrAYxJUU0AYSbBb5Tqgogbp_tMuSpKWR8G6Jja6CSAU23tdOYgZblRzy-e4hIKSeVsJFtNxm1TBC7IbmFqWiYUQvbQIw2UviSiiH02sB2dXlTNeKpxFcmOMBr65RUuvQuT09aLtuDXzs\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a view folder in the existing code directory.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/cQSWRBaPCdCVmhIAwko6gYRkLRKQlyi4IdZhwOKjPchQjV72hj1RySpu9Xds9wixA4tslVf8AYPboz7tcGzmVI2YaplXZLEKqGwTGZDJ9req-z_1oZs7KFikr5yhM-FT6EEMCvx5byAq8co9JDnQDdM\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Create a file with the name flash.ejs inside the views folder.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/qlL2KkPlaRceBHV1MOKBygQSGX7p76st7tQoXfDtQHsskeZNZ59Q3yKFXWGrN-WPsgGC1ZSl5bfEzO7hgwyYpJtpVe4g7K9MLtgcjTSf3DbnhmgCxqlZ_kOav6WC-USsOCafkB7h1mBGCjr5-Dc8aU0\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Open the flash.ejs file and add the below code in it. This will print the message on the application.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ohzHdZ50KMA-7MkNVKJT4qSZW0UD-7IHS4mtcwYHWfYpKR8y-QvQN4Rs7ybz1xD8cHkWwBamYIKQI5_5lmYxsRpsrDyHfsOQQ0MWLIJms3wYf5gIP3l5GZtvIuKvaxAFie8f9C96Z0CAPOh_Mf4PYUY\" alt=\"\"\/><\/figure>\n\n\n\n<p>Alter the flash-message route to the following code so that it renders the flash ejs file on hitting the URL.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/AQFzmeDd7RIGJNzya9om3i_GgU4GubZ8d_CqZyEwDbpjhLsxBpBfWp-dY9BNDC0NyLwqPHmgCLBU5JEKfGNI1hyDCSVt-yQh3heSvho2diglu3c8gmjwP7KRxf-lAyzKMENW7aLkPftUJBY0YoHBKyY\" alt=\"\"\/><\/figure>\n\n\n\n<p>Adding the above code snippets, the entire code looks like as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/DKCzTEq5l67OXe6tRXJcKT5uYwjfNMg--eyhOpTK2fz8yOpTOdLYVgbmPaCMy5PVpI_2PlmPkyJJ1beSUTRTzOhiNVhBbAp_TrtGyoDDCFSXsUw-bgQzr04R6M_VcqchjTPUZwXGT4wGndldfD7-ZAY\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Restart the server using the command:<\/p>\n\n\n\n<p><code>node index.js<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/7TVnOtaTfWfoykwdvgevZD4rpq_8hzTca0ijMpE5Js8m1omoPkbyW_PWnHOLWCPQb-A0fAPbPIvUks6jwJNtHVZAC8jziOMRzb3ksRwowGl3hfYtbmBw949O8sAXbmPblVh9d9gEXBf9GbHVdgJBd3g\" alt=\"\"\/><\/figure>\n\n\n\n<p>Hit the following URL on any of the browsers.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ne8nEAKuDIueGYnO6FyCtE7_sKwpxbZObdMZuiroXaZ5QWQ7KRR6zuEL2bqDWSS6GBGmFBO7aQFrJq8mpAwygxmykFJKnB3WpwSB4T3CMy4un8j1izpAwkfKk3D2WXwznDO5bOepK7DD5_RSZmpf6LM\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, you will see the message on the screen as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/CgJ5x2nPwv2PhjLksMzEQsVbWOLF_YHCCSBiTp589Xm6e2d2xDO_3aUiwyIJYVMPzPuVP9sTUSEnKxA6psjDv_lgvzcGzvXY_JEsXeMHdPeJDXvklr61yCmob8_c-PYcPvSeDyZW4GqRy8WKjTV5AgM\" alt=\"\"\/><\/figure>\n\n\n\n<p>Let&#8217;s beautify the message that is being displayed on the screen. To do so, add the following code to the index.ejs file.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/0wNZmjFesVeOHb2bNaG05e0m4kSRhNm7LMpzidAb_Uon8YnhfWQB6wQjVKk43L8bIV4zMopYhQF1DY3V-RdIL8mp7x_lyfrCYi7a_plAlhTAVmqL0Youowg_HL6N3q31opVMQTEsPyq2mFysj-L4f78\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>Restart the server using the command:<\/p>\n\n\n\n<p><code>node index.js<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/7TVnOtaTfWfoykwdvgevZD4rpq_8hzTca0ijMpE5Js8m1omoPkbyW_PWnHOLWCPQb-A0fAPbPIvUks6jwJNtHVZAC8jziOMRzb3ksRwowGl3hfYtbmBw949O8sAXbmPblVh9d9gEXBf9GbHVdgJBd3g\" alt=\"\"\/><\/figure>\n\n\n\n<p>Hit the same URL on any of the browsers.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ne8nEAKuDIueGYnO6FyCtE7_sKwpxbZObdMZuiroXaZ5QWQ7KRR6zuEL2bqDWSS6GBGmFBO7aQFrJq8mpAwygxmykFJKnB3WpwSB4T3CMy4un8j1izpAwkfKk3D2WXwznDO5bOepK7DD5_RSZmpf6LM\" alt=\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"\/><\/figure>\n\n\n\n<p>On success, you will see the beautified message displayed on the screen.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/PnBjyG5ZB-KmoHFEcRjGkYbGurOGt72bRMVyJGPOWu0ohypXn58HDypAnaCijyRVCGNC-WGsxvv8LOYPCCpU_jGsBpXLEUz8bcZjIpDHHNDjt8Yx0yEAGV0hwQUT4mQJy44WIMTYGJ46Gpk6nwmtl-k\" alt=\"\"\/><\/figure>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this hands-on, we had a look at how we can display flash messages on a webpage whenever needed (ie. Based on displaying a success or failure message pop-up to a user). To do so, we first began with creating the package.json file and installing the required packages for successful results. Verifying the package installations, we then proceeded further and imported the packages into our codebase. Then we defined a port number where our application would run and we created a session secret to encrypt any personal information. Followed by that, we defined the routes as to where the message is to be displayed on hitting a specific URL. Testing out the same, we installed the ejs view engine, created a template, beautified the message display file, altered the main codebase to accommodate the same, and finally restarted the server to test out the execution. We will come up with more such use cases in our upcoming blogs.<\/p>\n\n\n\n<p><strong>Meanwhile\u2026<\/strong><\/p>\n\n\n\n<p>If you are an aspiring Node.js developer and want to explore more about the above topics, here are a few of our blogs for your reference:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-create-and-delete-email-templates-on-amazon-ses-using-node-js-and-postman-api\/\">How to create and delete Email Templates on Amazon SES using Node.js and Postman API?<\/a><\/li><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/\">How to send customized emails by integrating SendGrid with a Node.js application?<\/a><\/li><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-connect-to-mysql-database-and-run-crud-operations-in-node-js\/\">How to connect to MySQL database and run CRUD operations in Node.js?<\/a><\/li><\/ul>\n\n\n\n<p>Stay tuned to get all the updates about our upcoming blogs on the cloud and the latest technologies.<\/p>\n\n\n\n<p><strong>Keep Exploring -&gt; Keep Learning -&gt; Keep Mastering&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">At <a href=\"https:\/\/www.workfall.com\/\">Workfall<\/a>, we strive to provide the best tech and pay opportunities to kickass coders around the world. If you\u2019re looking to work with global clients, build cutting-edge products and make big bucks doing so, give it a shot at <a href=\"https:\/\/www.workfall.com\/partner\/\">workfall.com\/partner<\/a> today!<\/p>\n\n\n\n<p><\/p>\n\n\n<style type=\"text\/css\"><\/style><section id='' \n                class='helpie-faq accordions faq-toggle open-first groupSettings-531__enabled' \n                data-collection='' \n                data-pagination='0' \n                data-search='0' \n                data-pagination-enabled='0'\n                role='region'\n                aria-label='FAQ Section'\n                aria-live='polite'><h3 class=\"collection-title\">Frequently Asked Questions:<\/h3><article class=\"accordion \"><div class='helpie-faq-row'><div class='helpie-faq-col helpie-faq-col-12' ><ul><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3047\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3047\"\r\n                data-id=\"post-3047\" \r\n                data-item=\"hfaq-post-3047\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. What are flash messages in a web application?<\/div><\/div><div id=\"accordion-content-post-3047\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3047\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">7<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">Flash messages are temporary notifications (e.g., \u201cLogin successful\u201d or \u201cInvalid password\u201d) that persist only for the next request-response cycle and are commonly used for user feedback.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3048\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3048\"\r\n                data-id=\"post-3048\" \r\n                data-item=\"hfaq-post-3048\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. How does connect-flash work in Express.js apps?<\/div><\/div><div id=\"accordion-content-post-3048\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3048\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">7<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">connect-flash<\/span><span style=\"font-weight: 400\"> uses sessions to store messages. When you set a flash message (e.g., <\/span><span style=\"font-weight: 400\">req.flash(&#8216;info&#8217;, &#8216;Message text&#8217;)<\/span><span style=\"font-weight: 400\">), it is stored in the session and then cleared after being displayed once.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3049\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3049\"\r\n                data-id=\"post-3049\" \r\n                data-item=\"hfaq-post-3049\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. What are the prerequisites for using connect-flash?<\/div><\/div><div id=\"accordion-content-post-3049\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3049\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">7<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">You need Express.js, <\/span><span style=\"font-weight: 400\">express-session<\/span><span style=\"font-weight: 400\">, and a view engine (like EJS, Pug, or Handlebars) to render the flash messages.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3050\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3050\"\r\n                data-id=\"post-3050\" \r\n                data-item=\"hfaq-post-3050\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. How do you display flash messages in templates?<\/div><\/div><div id=\"accordion-content-post-3050\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3050\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">7<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">\u00a0In EJS for example:<\/span><\/p>\n<p><span style=\"font-weight: 400\">&lt;% if (messages.error) { %&gt;<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0&lt;p class=&#8221;error&#8221;&gt;&lt;%= messages.error %&gt;&lt;\/p&gt;<\/span><\/p>\n<p><span style=\"font-weight: 400\">&lt;% } %&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">where <\/span><span style=\"font-weight: 400\">messages<\/span><span style=\"font-weight: 400\"> comes from <\/span><span style=\"font-weight: 400\">req.flash()<\/span><span style=\"font-weight: 400\">.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3051\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3051\"\r\n                data-id=\"post-3051\" \r\n                data-item=\"hfaq-post-3051\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. Can flash messages be styled and categorized?<\/div><\/div><div id=\"accordion-content-post-3051\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3051\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">7<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">Yes, you can define categories like <\/span><span style=\"font-weight: 400\">success<\/span><span style=\"font-weight: 400\">, <\/span><span style=\"font-weight: 400\">error<\/span><span style=\"font-weight: 400\">, <\/span><span style=\"font-weight: 400\">warning<\/span><span style=\"font-weight: 400\">, and style them differently using CSS frameworks like Bootstrap or Tailwind.<\/span><\/p>\n<\/div><\/li><\/ul><\/div><\/div><\/article><\/section>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">7<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> The Node.js Connect-flash module is extremely useful for developers whenever a flash message needs to be sent. When a user is redirected to a specific webpage, the connect-flash module in Node.js allows developers to display a pop-up message. For example, in your Node.js demo application, you might want to notify your users when they log [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1122,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[288],"tags":[328,182,265,250,266,6],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Show Flash Messages in Node.js using the Connect-flash Package? - The Workfall Blog<\/title>\n<meta name=\"description\" content=\"The Node.js Connect-flash module is extremely useful for developers whenever flash messages need to be sent.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Show Flash Messages in Node.js using the Connect-flash Package? - The Workfall Blog\" \/>\n<meta property=\"og:description\" content=\"The Node.js Connect-flash module is extremely useful for developers whenever flash messages need to be sent.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/\" \/>\n<meta property=\"og:site_name\" content=\"The Workfall Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/workfall\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-09T11:01:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-30T05:01:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@workfall\" \/>\n<meta name=\"twitter:site\" content=\"@workfall\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Workfall\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\",\"name\":\"Workfall - Hire #Kickass Coders On Demand\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/workfall\/\",\"https:\/\/www.linkedin.com\/company\/workfall\/\",\"https:\/\/facebook.com\/workfall\",\"https:\/\/twitter.com\/workfall\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"contentUrl\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"width\":400,\"height\":400,\"caption\":\"Workfall - Hire #Kickass Coders On Demand\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"name\":\"The Workfall Blog\",\"description\":\"#Tech #Remote #Jobs\",\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#primaryimage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png\",\"width\":1200,\"height\":628,\"caption\":\"Flash messages in Node.js\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#webpage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/\",\"name\":\"How to Show Flash Messages in Node.js using the Connect-flash Package? - The Workfall Blog\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#primaryimage\"},\"datePublished\":\"2022-08-09T11:01:30+00:00\",\"dateModified\":\"2025-09-30T05:01:40+00:00\",\"description\":\"The Node.js Connect-flash module is extremely useful for developers whenever flash messages need to be sent.\",\"breadcrumb\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learning.workfall.com\/learning\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Show Flash Messages in Node.js using the Connect-flash Package?\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#webpage\"},\"author\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\"},\"headline\":\"How to Show Flash Messages in Node.js using the Connect-flash Package?\",\"datePublished\":\"2022-08-09T11:01:30+00:00\",\"dateModified\":\"2025-09-30T05:01:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#webpage\"},\"wordCount\":1199,\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png\",\"keywords\":[\"flashmessages\",\"MOTT messages\",\"node\",\"nodeJS\",\"npm\",\"workfall\"],\"articleSection\":[\"Backend Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\",\"name\":\"Workfall\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"caption\":\"Workfall\"},\"sameAs\":[\"https:\/\/www.workfall.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Show Flash Messages in Node.js using the Connect-flash Package? - The Workfall Blog","description":"The Node.js Connect-flash module is extremely useful for developers whenever flash messages need to be sent.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/","og_locale":"en_US","og_type":"article","og_title":"How to Show Flash Messages in Node.js using the Connect-flash Package? - The Workfall Blog","og_description":"The Node.js Connect-flash module is extremely useful for developers whenever flash messages need to be sent.","og_url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/","og_site_name":"The Workfall Blog","article_publisher":"https:\/\/facebook.com\/workfall","article_published_time":"2022-08-09T11:01:30+00:00","article_modified_time":"2025-09-30T05:01:40+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@workfall","twitter_site":"@workfall","twitter_misc":{"Written by":"Workfall","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization","name":"Workfall - Hire #Kickass Coders On Demand","url":"https:\/\/learning.workfall.com\/learning\/blog\/","sameAs":["https:\/\/www.instagram.com\/workfall\/","https:\/\/www.linkedin.com\/company\/workfall\/","https:\/\/facebook.com\/workfall","https:\/\/twitter.com\/workfall"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","contentUrl":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","width":400,"height":400,"caption":"Workfall - Hire #Kickass Coders On Demand"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website","url":"https:\/\/learning.workfall.com\/learning\/blog\/","name":"The Workfall Blog","description":"#Tech #Remote #Jobs","publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#primaryimage","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png","width":1200,"height":628,"caption":"Flash messages in Node.js"},{"@type":"WebPage","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#webpage","url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/","name":"How to Show Flash Messages in Node.js using the Connect-flash Package? - The Workfall Blog","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#primaryimage"},"datePublished":"2022-08-09T11:01:30+00:00","dateModified":"2025-09-30T05:01:40+00:00","description":"The Node.js Connect-flash module is extremely useful for developers whenever flash messages need to be sent.","breadcrumb":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learning.workfall.com\/learning\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Show Flash Messages in Node.js using the Connect-flash Package?"}]},{"@type":"Article","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#article","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#webpage"},"author":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a"},"headline":"How to Show Flash Messages in Node.js using the Connect-flash Package?","datePublished":"2022-08-09T11:01:30+00:00","dateModified":"2025-09-30T05:01:40+00:00","mainEntityOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#webpage"},"wordCount":1199,"publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/#primaryimage"},"thumbnailUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png","keywords":["flashmessages","MOTT messages","node","nodeJS","npm","workfall"],"articleSection":["Backend Development"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a","name":"Workfall","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","caption":"Workfall"},"sameAs":["https:\/\/www.workfall.com"]}]}},"jetpack_featured_media_url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png","jetpack-related-posts":[{"id":1508,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-perform-encryption-and-decryption-of-messages-using-crypto-in-node-js\/","url_meta":{"origin":1121,"position":0},"title":"How to perform encryption and decryption of messages using Crypto in Node.js?","date":"November 8, 2022","format":false,"excerpt":"Web applications have access to massive amounts of data belonging to individuals, organizations, and governments. The more data that is accessed, the greater the risk to data security. Cryptography and encryption techniques are used by software developers to protect sensitive data from malicious parties. Cryptography is used to protect data\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"How to perform encryption and decryption of messages using Crypto in Node.js?","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/11\/Cover-Images_Part2-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1522,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-connect-to-mongodb-using-mongoose-and-mongodb-atlas-in-node-js\/","url_meta":{"origin":1121,"position":1},"title":"How to connect to MongoDB using Mongoose and MongoDB Atlas in Node.js?","date":"November 29, 2022","format":false,"excerpt":"MongoDB is one of the most popular No-SQL databases in the developer community today. Instead of SQL objects, No-SQL databases allow developers to send and retrieve data as JSON documents. In this blog, we will demonstrate how to connect to MongoDB using Mongoose and MongoDB Atlas in Node.js. Let\u2019s get\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"How to connect to MongoDB using Mongoose and MongoDB Atlas in Node.js?","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/11\/Cover-Images_Part2-1-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":930,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-connect-to-mysql-database-and-run-crud-operations-in-node-js\/","url_meta":{"origin":1121,"position":2},"title":"How to connect to MySQL database and run CRUD operations in Node.js?","date":"May 4, 2022","format":false,"excerpt":"In this blog, we will have a look at getting started with the MySQL npm package which is a Node.js client for connecting to MySQL, written in JavaScript. We will see how to use the package to connect to a MySQL database and perform the CRUD operations. We will begin\u2026","rel":"","context":"In &quot;Data Engineering&quot;","img":{"alt_text":"MySQL Database in Node.js","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":934,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-webhooks-using-python-and-receive-via-node-js-applications\/","url_meta":{"origin":1121,"position":3},"title":"How to send Webhooks using Python and receive via Node.js Applications?","date":"May 10, 2022","format":false,"excerpt":"If you are a Facebook user, you are using Webhooks unknowingly :) . For example, whenever your close friend posts something new or comments on your Facebook posts, there is an event that will take place and a post request will be created that will serve you with a notification\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"Webhooks using Python","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1397,"url":"https:\/\/learning.workfall.com\/learning\/blog\/pm2-daemon-process-manager-for-a-node-js-application\/","url_meta":{"origin":1121,"position":4},"title":"How to set up a PM2 daemon process manager for a Node.js application?","date":"October 4, 2022","format":false,"excerpt":"Process management encompasses a wide range of activities centered on the creation, termination, and monitoring of processes. A process manager is a program that ensures that your applications remain operational after they have been launched. Process managers can prevent production downtime by restarting your application automatically after a crash or\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"How to set up a PM2 daemon process manager for a Node.js application?","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/10\/Cover-Images_Part2-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":226,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-build-and-deploy-a-mern-stack-application-on-aws\/","url_meta":{"origin":1121,"position":5},"title":"How to build and deploy a MERN Stack Application on AWS?","date":"October 27, 2021","format":false,"excerpt":"Do you have a wonderful product idea that keeps springing into your head? However, not sure which technology or framework to adopt for easier and faster deployment of scalable web applications, you can go for MERN Stack.\u00a0 A MERN Stack is a collection of front-end, back-end, and database components that\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Build and Deploy a MERN Stack Application on AWS","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/MERN.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/1121"}],"collection":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/comments?post=1121"}],"version-history":[{"count":6,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/1121\/revisions"}],"predecessor-version":[{"id":3053,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/1121\/revisions\/3053"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media\/1122"}],"wp:attachment":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media?parent=1121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/categories?post=1121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/tags?post=1121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}