The upcoming Elixir Phoenix 1.8 release looks awesome
* UI tweaks
* Simplification
* Security upgrades
Lots of things I've wanted are there:
- DaisyUI
- Magic links
- Light/dark mode
- Scopes for resources
- Layout organization improvements
- Pub/Sub generated for resources (with LiveView)
After reading the latest announcement I created a few test apps to check out the changes...
## Scopes
*Scopes* are probably the biggest deal.
Resources should almost always be scoped to prevent IDOR and similar security issues. You need to scope at least to resource creator/owner and often you have an organization, group etc. that it belongs to.
So without scopes built-in, you're going to gradually create an ad-hoc version. I've done this a few times. It's just tedious and sometimes awkward.
Now when you run `mix.gen.auth` you create a Scope which applies to future resources you generate.
Generators that used to give you list_items/0 or get_item!(id) will now create scoped function like:
- list_items(%Scope{} = scope)
- get_item!(%Scope{} = scope, id)
## PubSub
PubSub is already nicely built into Phoenix, but now the LiveView generator will build the PubSub into the Context module directly and into the LiveView.
Say you have a ToDo app: every ToDo item that's CRUDed will broadcast the change, and LiveView is generated to subscribe on mount and react to changes.
It's all stuff that was never hard to write yourself, but it's good to have this built-in as a pattern.
## Security
Aside from the move to magic links, I also see improvements to the docs and code comments explaining security concerns.
## UX
There are a bunch of little things that aren't so little, like having light/dark mode just built in, and DaisyUI now officially "part of" Phoenix.
## Simplification
The way Layouts work makes more sense now, but I won't get into it -- it's explained pretty well in the blog post.
Similarly it's good there's been an effort to simplify CoreComponents although I didn't delve deeply into that yet.