1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SanctumでLaravel 11とNext.js(v14 App router)を利用した認証機能を実装していく

Last updated at Posted at 2024-08-04

Videotogif (8).gif

前提

の記事の続きになりますが、認証機能の実装方法自体はその他の構成でも参考になると思います!

実装

上の記事の続きから次の実装を行なってください。

実装内容 

実装はGithubの方にまとめているのでそれをそのまま実装してください。

※package.jsonとかpackage_lock.jsonの実装はもちろん行わなくて大丈夫です!

画面確認までの準備

実装を終えたら

npm インストール

docker-compose exec next bash

でNext.jsのコンテナに入って、

npm install axios humps js-cookie next @mui/material @mui/icons-material
npm install @emotion/react @emotion/styled
npm install --save-dev @types/js-cookie @types/react @types/react-dom @types/node
npm i --save-dev @types/humps
npm i --save-dev @types/js-cookie

を実行してください。

node_moduleのコピー

ホスト(コンテナの外)で

docker cp sys1-nextjs:/app/node_modules ./next/

を実行してください。

next/.env

next/.env.example をコピーして next/.envを作ります。

Laravelの用意

docker-compose exec api bash

でLaravelのコンテナに入って、

php artisan migrate
php artisan db:seed

を実行します。

準備完了

そうすると以下の画面で動作を確認できるようになります。

URL一覧(ローカル環境)

動作としては冒頭のキャプチャと同じですがこんな感じになります。

Videotogif (8).gif

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?