DOKL57
Hello! I stuck with the display flash at my LiveView template. And whatever I do, I don’t see the message on the page. I have two fields and handle_event. The content of the handle event isn’t important, but it’s important to understand that if I write an IO.input in it, I get a message in the console. But if I try to put_flash, nothing will happen
def handle_event("click", %{"content" => params}, socket) do
IO.inspect("test") # I see "test" in console
put_flash(socket, :error, "Error!") # I don't see flash on page
{:noreply, socket}
end
I also tried to write code like this:
def handle_event("click", %{"content" => params}, socket) do
IO.inspect("test") # I see "test" in console
# I don't see flash on page
{:noreply, socket |> put_flash(socket, :error, "Error!") }
end
and nothing happens.
Why don’t see flashes on the page? Could this be because tailwind and alphine.js were installed?
Trending in Questions
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
Hi all!
I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
Hello everyone!
I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++.
Does anyone ...
New
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
Hey, I know this has been discussed ad nauseum, but I couldn’t find a definitive answer or at least some consensus around this, so let me...
New
I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ ...
New
Hey everyone, I have been building a lightweight Phoenix backend aimed at backing up and synchronizing user profiles across mobile device...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
Hi everyone :waving_hand:
I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #code-sync
- #exunit
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #ai
- #authentication
- #elixirconf-us
- #umbrella
- #full-time-contract
- #blog-post
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-eu
- #distillery
- #security
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
moogle19
Hi,
since Elixir variables are immutable the
put_flash/3in your first example doesn’t change your socket, but returns a new socket which you have to use.In the second example you have to remove the
socketfrom theput_flash. The pipe (|>) calls the next function with the return value of the previous one as first parameter automatically.Your
socket |> put_flash(socket, :error, "Error!")is the same asput_flash(socket, socket, :error, "Error!"), but you only want it once inside the call.You could use either:
or
DOKL57
Thanks for your answer! I changed code to
but still got nothing. I’m inclined to believe that the display error is due to the tailwind css setup.
moogle19
Normally the displaying of the flashes is handled by the css.
In a default phoenix project there is something like:
and the flash inside the live template is defined like this:
Did you make changes to either of these?
DOKL57
Nope. My live.html.heex here:
And app.css contains:
moogle19
Hmm, strange.
Do you have
:fetch_live_flashin the pipeline in your router?Sebb
you have to use a layout in your liveview like
see: Live layouts — Phoenix LiveView v1.2.5
scoop
As a follow up to a question I asked earlier on the forum regarding implementing functions to be invoked from the templates.
In this case, one would perhaps use
Phoenix.LiveView.JSto compose several JS commands to extend the generated flashes. I’m thinking of Chris McChord’s demo for the release of LiveView 0.17.Where would such code reside?
chrisdel101
EDIT: SOLVED I tried this and it WORKED, i.e. calling inside
handle_event. Delgating to another functionsendcaused it to fail. I wasn’t sending the socket back tohandle_eventproperly (I guess)I have this problem too. I’ve tried all the suggestions above.
Notes:
default alert html is from
live.html(not app.html.heex) as theclass=XXXXXXXXXXXis on the page. This happens even if I remove the layout definitionuse Phoenix.LiveView, layout...non-live views have the
app.html.heexflash layout as expectedThe flash message does not display, and the message text is not injected
The flash is appended to the socket as expected. So seems problem is that socket data is not making the html changes to the page.
This is a rough example of my code setup.
index.ex
live.html (layout called above)
router
PrincetonPoh
Hi @DOKL57, sorry but I don’t understand the solution at all. It’s too complicated. After pulling my beginner hairs out, I found the solution to be super simple!!!*.
You tried 2 methods in your original code. First:
^for this, the solution is simple. Do not return
{:noreply, socket}. Instead, you should return{:noreply, put_flash(socket, :error, "Error!")}. Here’s a working example:For your second approach here:
^the solution is mentioned above by moogle19. You’re piping the socket into the put_flash() which means you’re actually writing put_flash(socket, socket, :error, “Error!”). Hence the error.
From moogle19’s explanation that “Elixir variables are immutable and the put_flash returns a new socket”, I looked again at what my function was returning and so found the solution to the bug in your first approach.
manicar2093
Hi!. I don’t know if this can help. I did have the same problem but in a LiveComponent Form. I put_flash a message but it wasn’t displayed. I noticed LiveComponent does not use <.flash_group flash={@flash} /> in layout but if you add this in your LiveComponent will work
Its kind of weird. I thougth layout component would be used