Skip to content

Add opt-in teams to the starter kit - #45

Merged
skryukov merged 12 commits into
mainfrom
feat/teams
Nov 25, 2026
Merged

skryukov merged 12 commits into
mainfrom
feat/teams

Conversation

@skryukov

Copy link
Copy Markdown
Member

What

INERTIA_TEAMS=1 (or the new prompt, default no) adds teams to the starter kit, for React, Vue and Svelte. It is a port of the teams branch of Laravel's starter kits.

INERTIA_FRAMEWORK=react INERTIA_STARTER_KIT=1 INERTIA_TEAMS=1 \
rails new myapp -m https://inertia-rails.dev
  • A personal team for every user, plus any number of shared teams
  • Three roles, checked with Action Policy: owner (everything), admin (rename, invite), member (view, leave)
  • Email invitations. The email links to the sign in page, which says which team the visitor was invited to; the invitation is then accepted or declined from a modal on the dashboard. Expired invitations are deleted daily (Solid Queue recurring task)
  • A team switcher in the sidebar and the header, and team settings under Settings → Teams (rename, members, roles, invitations, delete)
  • Team pages live under /:team_slug/..., so links, bookmarks and browser tabs keep pointing at the same team. Opening a team's page makes it the current team

How it is built

  • Backend lives in template/shared/starter_teams and is copied on top of the starter backend. Existing files that need a few extra lines (User, ApplicationController, routes, shared props) carry <% if use_teams %> blocks instead of being duplicated.
  • Frontend follows Laravel's files one to one (same screens, dialogs and labels). Only what our kits force is different: Field components, Typelizer route helpers, snake_case props.
  • /dashboard stays as a redirect to the current team's dashboard, so sign in, sign up and existing links keep working without changes.
  • Alba is supported: serializers in template/shared/starter_teams_alba, and the generated types replace the hand-written ones as before.
  • Tests ship for RSpec and minitest, including two browser tests.

Published kits

The sync workflow now generates every kit twice and opens two PRs per kit: one against main as before, one against a teams branch (generated with INERTIA_TEAMS=1). The first run creates the teams branch from main.

Where it differs from Laravel, on purpose

  • Invitations are only shown to users with a verified email address, since they are matched by email.
  • Switching team has no endpoint of its own: opening the team's URL switches.
  • Teams are deleted for real (no soft delete).
  • Deleting an account is refused while it owns a team other people belong to. Teams nobody else belongs to are deleted with the account.
  • Sending invitations is rate limited (10 per 3 minutes), like the other auth endpoints.

Kits without teams

Three one-line changes:

  • the settings menu highlights an item for nested pages too (startsWith)
  • the sign in spec checks an authenticated page that is not the dashboard
  • the "delete account" test signs in as the second fixture user

Verified

  • Kits generated with teams pass type check, lint, format, RuboCop and their full suites for React, Vue and Svelte (RSpec), and for React with Alba + minitest. That includes the browser tests.
  • A wider one-off browser pass (not shipped) covered: invite with a role and the "already a member" error, change role, remove member, cancel invitation, rename, delete with name confirmation, the read-only member view, leave, decline, the sign in / sign up note, refused account deletion, and the switcher in the header layout.
  • Kits generated without teams were diffed against the published kits: only the three lines above differ.
  • rake test (256 runs) and standardrb pass; the new svelte_starter_kit_teams e2e config passes.

Not verified

  • The sync workflow change has not run yet.
  • Alba together with Vue or Svelte.

INERTIA_TEAMS=1 (or the prompt, default no) adds teams to the starter
kit, ported from Laravel's starter kits for React, Vue and Svelte:

- a personal team per user, plus shared teams
- owner/admin/member roles checked with Action Policy
- email invitations, accepted or declined from the dashboard; the
  email links to the sign in page, which shows what the visitor was
  invited to; expired invitations are deleted daily
- team switcher and team settings pages
- team pages under /:team_slug, with /dashboard redirecting to the
  current team so sign in and existing links keep working

Deleting an account is refused while it owns a team other people
belong to.

The sync workflow now also generates each kit with teams and opens a
PR against a teams branch in the kit repo.

Kits without teams change in three one-line places: the settings menu
highlights nested pages, and two tests no longer depend on the
dashboard or on the first fixture user.
Type team roles with the MembershipRole enum Typelizer generates from
the model, and give permissions their own serializer, so the Alba
variant no longer repeats the role and permission names as strings.
The hand-written TeamPermissions type is dropped there, like the other
types the serializers generate.
Give the invitation context its own serializer instead of a raw
TypeScript string repeated in two page serializers, and name the role
type MembershipRole, as Typelizer does. In Alba kits both hand-written
types are now removed in favour of the generated ones.
Pages declared their props by hand even in kits where Typelizer
generates the same types from the page serializers.

Pages now import the props type by the name the serializer generates
(SettingsTeamsShow, SessionsNew, ...). Kits without Alba keep a
hand-written copy in types/index.ts; Alba kits strip it, like the
model types, so the generated one is used.
@skryukov
skryukov merged commit 913c2da into main Nov 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant