<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: hirooka kazuya</title>
    <description>The latest articles on Forem by hirooka kazuya (@hirooka_kazuya_d7f37d3cde).</description>
    <link>https://forem.com/hirooka_kazuya_d7f37d3cde</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3595695%2Ffbed1c54-f177-4451-b6b2-21ef62461df1.png</url>
      <title>Forem: hirooka kazuya</title>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hirooka_kazuya_d7f37d3cde"/>
    <language>en</language>
    <item>
      <title>dev diary 20251124</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Tue, 25 Nov 2025 00:07:02 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251124-4bb7</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251124-4bb7</guid>
      <description>&lt;h2&gt;
  
  
  frustration to voice talking
&lt;/h2&gt;

&lt;p&gt;i sometimes voice talk with AI chat, feel like, wanna make conversation with AI more smooth. now there is frustration with it. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;bad turn taking process&lt;/li&gt;
&lt;li&gt;not promote and built conversation but just answer to question&lt;/li&gt;
&lt;li&gt;just repeat same contents to my opinion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  background
&lt;/h2&gt;

&lt;p&gt;the voice talking is more natural and stress free communication for human, so far there are several service like siri, areksa and so on. but they are not mutual conversation but just one-direction process, request and answer something.&lt;br&gt;
but if we use current AI technology, we can build more natural and powerful tool specialized for conversation, that realize same experiences of human-to-human conversation.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>dev diary 20251123</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Mon, 24 Nov 2025 00:10:57 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251123-38pd</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251123-38pd</guid>
      <description>&lt;h2&gt;
  
  
  organizing app UI
&lt;/h2&gt;

&lt;p&gt;i organized the UI of application and then built menu button and slide bar to show user name, existing table and sign out all in one.&lt;/p&gt;

&lt;h2&gt;
  
  
  the policy of UI
&lt;/h2&gt;

&lt;p&gt;i have to make policy of UI. button click, input text, font, color, and so on. if there is already some general policy in this field, i'll check it.&lt;/p&gt;

&lt;h2&gt;
  
  
  read and understanding code
&lt;/h2&gt;

&lt;p&gt;i built almost the all coding with ai, so don't understand detail, i have to read and comprehend them. in order to make countermeasure at trouble shooting, or expand some function on them.&lt;/p&gt;

&lt;h2&gt;
  
  
  basement for future application
&lt;/h2&gt;

&lt;p&gt;i regard this front and backend code as basement and i wanna develop new application on it. this has basic CRUD function, list page and detail edit page, sidebar for menu.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>ui</category>
      <category>ai</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>dev diary 20251122</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Sun, 23 Nov 2025 02:53:19 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251122-aed</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251122-aed</guid>
      <description>&lt;h2&gt;
  
  
  getting user information after sign in.
&lt;/h2&gt;

&lt;p&gt;with AWS amplify gen2 and next.js, how to get user information after sign in ? in previous version of amplify gen1, Authenticator's user object has all the user information and can be get ,for example, by 'user.attribute.nickname'. but now actually i can't get with this user object.&lt;/p&gt;

&lt;h2&gt;
  
  
  user information from 'fetchUserAttributes'
&lt;/h2&gt;

&lt;p&gt;instead, i use 'fetchUserAttributes' to get user profile. the code is following;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fetchUserAttributes&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-amplify/auth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;UserAttributes&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userAttributes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setUserAttributes&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UserAttributes&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getUserAttributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetchUserAttributes&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nf"&gt;setUserAttributes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;attributes&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;UserAttributes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error fetching user attributes:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setUserAttributes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this userAttributes has the information. and we get it with 'userAttributes.nickname' by each property.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>typescript</category>
      <category>aws</category>
    </item>
    <item>
      <title>div diary 20251121</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Sat, 22 Nov 2025 00:30:36 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/div-diary-20251121-2gpk</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/div-diary-20251121-2gpk</guid>
      <description>&lt;p&gt;i studied the auth/resouce.ts and the corresponding frontend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/page.tsx

'use client'
import { Authenticator } from '@aws-amplify/ui-react';
// 💡 以下は、ご自身のプロジェクト構成に合わせてインポートパスを確認してください
import NotesList from '../app/dashboard/page'; 
import UserProfileEditor from './setting/userProfileEditor';

// 💡 stylesのインポートも、ご自身のファイルパスに合わせて確認してください
import styles from './app.module.css';

export default function DashboardPage() {
  return (
    &amp;lt;Authenticator&amp;gt;
      {({ signOut, user }) =&amp;gt; {

        // --- ログイン中のユーザー情報をコンソールに出力 ---
        console.log("--- ログイン中の User オブジェクト ---");
        // この user オブジェクトに、ユーザー情報や属性が含まれています
        console.log(user); 
        console.log("---------------------------------------");

        // --- 表示名の取得 ---
        // user?.attributes?.nickname を優先的に使用し、存在しない場合は 'Guest' を表示名とする
        // user?.username は sub の値（UUID）になるため、ここでは nickname を使用します
        const displayNickname = user?.attributes?.nickname ?? 'Guest';

        return (
          &amp;lt;main&amp;gt;
            {/* &amp;lt;h1&amp;gt;Hello, {user?.username}!&amp;lt;/h1&amp;gt; をニックネーム表示に変更 */}
            &amp;lt;h1&amp;gt;Hello, {displayNickname}!&amp;lt;/h1&amp;gt;

            &amp;lt;UserProfileEditor user={user} /&amp;gt;

            &amp;lt;NotesList /&amp;gt; {/* 👈 NotesListコンポーネントを配置 */}

            &amp;lt;button 
              className={styles.signOutButton} 
              onClick={signOut}
            &amp;gt;
              sign out
            &amp;lt;/button&amp;gt;
          &amp;lt;/main&amp;gt;
        );
      }}
    &amp;lt;/Authenticator&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;by this console.log, the result is following,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "username": "******",
    "userId": "******",
    "signInDetails": {
        "loginId": "***mail.adress",
        "authFlowType": "USER_SRP_AUTH"
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this object don't have the "attribute", it should be. now i'm confirming. i guess need to use &lt;code&gt;import { fetchUserAttributes } from 'aws-amplify/auth';&lt;/code&gt; current spec.&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>nextjs</category>
      <category>react</category>
      <category>aws</category>
    </item>
    <item>
      <title>dev diary 20251120</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Fri, 21 Nov 2025 00:16:45 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251120-kjn</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251120-kjn</guid>
      <description>&lt;p&gt;today i didn't sleep well, so my brain doesn't work. at least once a week there are such a days, stand with some music, soft drink, ect...&lt;/p&gt;

&lt;h2&gt;
  
  
  setting user name in app
&lt;/h2&gt;

&lt;p&gt;on site display, there is the "hello ! ****" this user name is something kind of hash code because i don't set the username in this app. so i study how to set the username in this app,&lt;br&gt;
in /amplify/data/resouce.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { defineAuth, secret } from "@aws-amplify/backend";

export const auth = defineAuth({
  loginWith: {
    email: true,
  },
  userAttributes: {
    nickname: {
      required: true, 
      mutable: true, 
    },

    familyName: { 
      required: false, 
      mutable: true,
    },
    givenName: { 
      required: false, 
      mutable: true,
    },
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and in app/setting/userProfileEditor.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/setting/UserProfileEditor.tsx
'use client'
import React, { useState } from 'react';
import { updateUserAttributes } from 'aws-amplify/auth';

// 実際のAmplifyの型に合わせて詳細に定義しても良いですが、
// ここでは必要な構造だけを持つシンプルなインターフェースを定義します。
interface UserAttributes {
  nickname?: string;
  // 他に必要な属性（familyName, givenNameなど）があればここに追加
  [key: string]: any; // その他の属性を許容
}

interface UserProps {
  // Amplifyのユーザーオブジェクトはより複雑ですが、
  // attributesとusernameがあれば表示と更新には十分です。
  attributes?: UserAttributes;
  username?: string;
}

const UserProfileEditor = ({ user }: { user: UserProps }) =&amp;gt; {
  // ユーザーの現在のニックネームを取得（未設定なら空文字）
  // 属性名はバックエンドの定義と同じ「nickname」を使用
  const initialNickname = user?.attributes?.nickname || '';
  const [nickname, setNickname] = useState(initialNickname);
  const [message, setMessage] = useState('');

// src/components/UserProfileEditor.tsx (handleUpdate 関数内)

const handleUpdate = async () =&amp;gt; {
  setMessage('');
  try {
    // 戻り値のオブジェクト全体を受け取る
    const output = await updateUserAttributes({
      userAttributes: {
        nickname: nickname,
      },
    });

    // 💡 修正点 1: nextStep の有無と、その中のプロパティを確認する
    if (output.isUpdated) {
      // isUpdated プロパティが true の場合、更新が完了したことを示します
      setMessage('ニックネームが更新されました！');

    } else if (output.nextStep &amp;amp;&amp;amp; output.nextStep.updateAttributeStep === 'CONFIRM_ATTRIBUTE_WITH_CODE') {
      // 💡 修正点 2: output.nextStep が存在し、
      // その中の updateAttributeStep プロパティを確認します

      // 確認コードが必要な場合の処理を記述
      setMessage('更新には確認コードの入力が必要です。'); 
      // 例: 確認コード入力フォームを表示する処理など

    } else {
       // その他の状態 (基本的に属性の更新では発生しにくい)
       setMessage('更新処理は完了しましたが、状態が確認できませんでした。');
    }

  } catch (error) {
    console.error('属性の更新に失敗しました:', error);
    // TypeScript環境下でエラーメッセージを使用する際、errorはunknown型になることがあるため、
    // 明示的にError型として扱うか、シンプルにメッセージを表示します。
    setMessage(`更新失敗: ${error instanceof Error ? error.message : '不明なエラー'}`);
  }
};

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h2&amp;gt;プロフィール編集&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;現在のニックネーム: {initialNickname || '未設定'}&amp;lt;/p&amp;gt;
      &amp;lt;input
        type="text"
        value={nickname}
        onChange={(e) =&amp;gt; setNickname(e.target.value)}
        placeholder="新しいニックネーム"
      /&amp;gt;
      &amp;lt;button onClick={handleUpdate}&amp;gt;ニックネームを保存&amp;lt;/button&amp;gt;
      {message &amp;amp;&amp;amp; &amp;lt;p&amp;gt;{message}&amp;lt;/p&amp;gt;}
    &amp;lt;/div&amp;gt;
  );
};

export default UserProfileEditor;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but now error occur at output.nextStep.updateAttributeStep&lt;/p&gt;

</description>
    </item>
    <item>
      <title>dev diary 20251119</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Thu, 20 Nov 2025 00:27:50 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251119-g91</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251119-g91</guid>
      <description>&lt;h2&gt;
  
  
  ideation for web app
&lt;/h2&gt;

&lt;p&gt;i generated the ideas for web app with Miro stickies. the Several ideas are written.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;notes to add revision with red color.&lt;/li&gt;
&lt;li&gt;notes without thinking integration&lt;/li&gt;
&lt;li&gt;automatically data analysis, multi step thinking with AI&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  format for CRUD
&lt;/h2&gt;

&lt;p&gt;i already built the pipe line to develop full stack app with aws amplify. and as the next step, i wanna prepare basic CRUD function as template for general usage. and i made it.&lt;br&gt;
[&lt;a href="https://github.com/hirookakazuya/20251119_app" rel="noopener noreferrer"&gt;https://github.com/hirookakazuya/20251119_app&lt;/a&gt;]&lt;/p&gt;

&lt;h2&gt;
  
  
  make the development folder clear
&lt;/h2&gt;

&lt;p&gt;each dev folder have storage of 1.2GB and the most of it is in node_modules folder.  as chatAI information, this node_module folder can be deleted and restored again with &lt;code&gt;install npm&lt;/code&gt; when i use it. i didn't try it.&lt;/p&gt;

&lt;h2&gt;
  
  
  cursor or claude code ?
&lt;/h2&gt;

&lt;p&gt;now i' using the cursor. but the limitation of monthly use come.  i study which tool i should select for code assistant. for basic use for dev, free ai chat bot is enough like chatGPT, Gemini. in these tool, i don't care about the limitation.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>dev diary 20251118</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Wed, 19 Nov 2025 00:41:37 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251118-555o</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251118-555o</guid>
      <description>&lt;h2&gt;
  
  
  ideation for web application
&lt;/h2&gt;

&lt;p&gt;i completed preparation of development too, then started to generate idea of application. with Miro. but i don't take so long time to do it. the plan is just plan. i wanna build some concrete things without consider detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  getting new insight from AI
&lt;/h2&gt;

&lt;p&gt;i use chatGPT, Gemini, Copilot, Claude or Perplexity everyday. but i guess there are more efficient way of use. especially, now i just input one question or reflection and get answer, but with AI agent, set multi steps, might get more deep reflection.&lt;/p&gt;

&lt;h2&gt;
  
  
  the status of the AI know everything i know
&lt;/h2&gt;

&lt;p&gt;if ai know everything about me, have all the information of myself, ai can think and judge same as me. ai hear everything i heard, read everything i read, have all the set of my input and output and work as RAG.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI reflect like human
&lt;/h2&gt;

&lt;p&gt;human encounter some issues, think and try to find how to shoot, but can't solve quickly, the day end, sleep, then next morning, sometimes the problem is solved, some solutions appear automatically. in the night, in brain, the issue is cultivated. such process can work in AI. input question and get answer, check, abstract task from it, and rethink, over and over.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>production deploy completed !</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Tue, 18 Nov 2025 00:24:52 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251117-177c</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251117-177c</guid>
      <description>&lt;h2&gt;
  
  
  AWS Amplify Gen2 deployment
&lt;/h2&gt;

&lt;p&gt;i tried to production deploy test code with amplify. I have already check the developing application work in sandbox. it' OK. &lt;/p&gt;

&lt;p&gt;in amplify gen2, the deploy of production is executed not by command prompt like the other process, but with aws console.&lt;/p&gt;

&lt;p&gt;after opening the aws amplify in aws console, it's easy to deploy along with the guide. the local application link to amplify through github repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  trouble shooting
&lt;/h2&gt;

&lt;p&gt;i tried production deployment like above, the deployment failed because of variant type of "moduleResolution". then my countermeasure is;&lt;br&gt;
the tsconfig.ts in project root folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ES2017"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lib"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"dom"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dom.iterable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"esnext"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"allowJs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"skipLibCheck"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"strict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"noEmit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"esModuleInterop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"esnext"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"NodeNext"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;変更&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"moduleResolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"NodeNext"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;変更&lt;/span&gt;&lt;span class="w"&gt;

    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;----------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;💡&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;修正&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;.ts拡張子のインポートを許可する設定を追加&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"allowImportingTsExtensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;

    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;💡&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;修正&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Next.js&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Amplify&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Gen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;で推奨される設定に調整&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"moduleResolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"NodeNext"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;----------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;

    &lt;/span&gt;&lt;span class="nl"&gt;"resolveJsonModule"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"isolatedModules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"jsx"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the original setting is default of next.js project. so in future at every time i build develop folder, it's necessary. &lt;/p&gt;

&lt;h2&gt;
  
  
  aws amplify gen2 pipe line completed !!
&lt;/h2&gt;

&lt;p&gt;in this process, i completed the product pipeline. if i update the application, i change the local file and then;&lt;br&gt;
&lt;code&gt;git add .&lt;/code&gt; staging upload&lt;br&gt;
&lt;code&gt;git commit -m "changing description"&lt;/code&gt; commit to local git&lt;br&gt;
&lt;code&gt;git push&lt;/code&gt; push to remote repository&lt;/p&gt;

&lt;p&gt;i can reflect the local change to product just with this !!&lt;/p&gt;

&lt;h2&gt;
  
  
  prepare to full stack app dev
&lt;/h2&gt;

&lt;p&gt;i have already prepared the full stack app dev. i keep this dev folder as template for the next.&lt;br&gt;
and now i have to focus on generate idea of my app.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devjournal</category>
      <category>typescript</category>
    </item>
    <item>
      <title>dev diary 20251116</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Mon, 17 Nov 2025 00:32:43 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251116-16k0</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/dev-diary-20251116-16k0</guid>
      <description>&lt;p&gt;I can't access the AWS console right now, so I'll go ahead and write yesterday's development log. Since it was a holiday and I had time, I think I made relatively good progress. I believe I can now set up the AWS Amplify Gen 2 sandbox with almost no issues (I gave up on real-time updates, though).&lt;/p&gt;

&lt;p&gt;Next, I proceeded with implementing the production environment deployment and subsequent updates, but I hit an error and stopped. I felt that if the sandbox works but the production deployment fails, then the sandbox is pointless, but I have to deal with it. I ended the day yesterday after repeating the build process several times at that point.&lt;/p&gt;

&lt;p&gt;Once this production deployment is complete, I should just be able to copy and paste the code and proceed with operations. Since Wednesday is a public holiday this week, I'll be able to dedicate time to this task then.&lt;/p&gt;

&lt;p&gt;In parallel with this work, I also need to spend time brainstorming application ideas. I'll create a workflow where I build and brainstorm simultaneously.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>summary of git management</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Sun, 16 Nov 2025 04:06:52 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/summary-of-git-management-3m9f</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/summary-of-git-management-3m9f</guid>
      <description>&lt;h2&gt;
  
  
  initial build of git repository
&lt;/h2&gt;

&lt;h3&gt;
  
  
  local git
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cd (project root directory)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit -m "Initial commit"&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  git hub on web
&lt;/h3&gt;

&lt;p&gt;making github repository on my account&lt;/p&gt;

&lt;p&gt;copying the URL of the repository&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git remote add origin (URL)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git remote -v&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push -u origin main&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  update of existing git repository
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit -m "コミットメッセージ"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push&lt;/code&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>github</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Roadmap to Full-Stack Application Completion with AWS amplify gen2 and Next.js</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Sun, 16 Nov 2025 03:40:30 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/roadmap-to-full-stack-application-completion-with-aws-amplify-gen2-and-nextjs-2jge</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/roadmap-to-full-stack-application-completion-with-aws-amplify-gen2-and-nextjs-2jge</guid>
      <description>&lt;h2&gt;
  
  
  🗺️ ロードマップ: DynamoDB前提 (Amplify Gen 2 &amp;amp; Next.js)
&lt;/h2&gt;

&lt;p&gt;アプリケーション開発は、主に &lt;strong&gt;バックエンド定義・デプロイ&lt;/strong&gt;、&lt;strong&gt;フロントエンド開発&lt;/strong&gt;、&lt;strong&gt;デプロイ・運用&lt;/strong&gt; の3つのフェーズで進行します。&lt;/p&gt;




&lt;h2&gt;
  
  
  🌟 Phase 1: バックエンド定義とデプロイ (Amplify Gen 2)
&lt;/h2&gt;

&lt;p&gt;このフェーズでは、アプリケーションの核となるクラウドインフラストラクチャをコードとして定義し、AWS上に構築します。&lt;/p&gt;

&lt;h3&gt;
  
  
  詳細ステップ
&lt;/h3&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;データスキーマの定義 (DynamoDB/AppSync)&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;amplify/data/resource.ts&lt;/code&gt; で、&lt;strong&gt;GraphQLスキーマ&lt;/strong&gt;としてデータモデル（例: &lt;code&gt;Todo&lt;/code&gt;）を定義します。&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;a.model()&lt;/code&gt; を使用してスキーマを記述するだけで、AWSの &lt;strong&gt;DynamoDB テーブル&lt;/strong&gt; と &lt;strong&gt;AppSync API&lt;/strong&gt; が自動的に生成されます。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;認証ルール&lt;/strong&gt;（例: &lt;code&gt;allow.publicApiKey()&lt;/code&gt; や &lt;code&gt;allow.owner()&lt;/code&gt;）もこのファイルで定義します。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;認証リソースのコード定義 (Cognito)&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;amplify/auth/resource.ts&lt;/code&gt; などのファイルで、ユーザー登録、ログイン、パスワード回復などの &lt;strong&gt;認証機能 (Cognito)&lt;/strong&gt; をコードで定義します（例: Eメールログインを有効化）。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;ローカル環境の検証 (Sandbox)&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npx ampx sandbox&lt;/code&gt; を実行し、開発リソースをAWSアカウント内にデプロイします。&lt;/li&gt;
&lt;li&gt;デプロイ後、認証機能と &lt;strong&gt;DynamoDB へのデータアクセス&lt;/strong&gt;（CRUD操作）が正しく機能するか検証します。
* ****&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;設定ファイルの取得&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;サンドボックス実行によって生成される &lt;code&gt;amplify_outputs.json&lt;/code&gt; ファイルを取得します。このファイルには、フロントエンドがバックエンドに接続するために必要な情報（API URL、Cognito IDなど）が含まれます。&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💻 Phase 2: フロントエンド開発 (Next.js / aws-amplify)
&lt;/h2&gt;

&lt;p&gt;このフェーズでは、ユーザーインターフェース (UI) とロジックを実装し、バックエンドと連携させます。&lt;/p&gt;

&lt;h3&gt;
  
  
  詳細ステップ
&lt;/h3&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Amplify 設定の初期化&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Next.js アプリケーションのエントリーポイント (&lt;code&gt;app/providers.tsx&lt;/code&gt;など) で、&lt;code&gt;aws-amplify&lt;/code&gt; ライブラリと手順4で取得した &lt;code&gt;amplify_outputs.json&lt;/code&gt; を使用して初期設定を行います。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;認証 UI の統合&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@aws-amplify/ui-react&lt;/code&gt; ライブラリを使用して、サインアップ/ログイン画面を実装し、バックエンドの &lt;strong&gt;Cognito 認証&lt;/strong&gt;機能と連携させます。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;データアクセスレイヤーの実装&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Amplify Data Client&lt;/strong&gt; (&lt;code&gt;aws-amplify/data&lt;/code&gt; から生成) を使用し、Next.jsのコンポーネント内で &lt;strong&gt;GraphQL&lt;/strong&gt; を介して &lt;strong&gt;DynamoDB&lt;/strong&gt; に直接アクセスする機能（データの表示、登録、更新など）を実装します。

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;※RDSの場合と異なり、Lambdaを経由せず、直接データアクセスが可能です。&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;UI/UX の完成&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;画面レイアウト、デザイン、ナビゲーションを含む、すべてのユーザー向け機能（CRUD操作）を完成させます。&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Phase 3: デプロイと本番運用 (Amplify Hosting)
&lt;/h2&gt;

&lt;p&gt;このフェーズでは、アプリケーションをグローバルに公開し、継続的な改善を行うための環境を整備します。&lt;/p&gt;

&lt;h3&gt;
  
  
  詳細ステップ
&lt;/h3&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Amplify Hosting の設定&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;プロジェクトを &lt;strong&gt;GitHub&lt;/strong&gt; などのバージョン管理システムにプッシュします。&lt;/li&gt;
&lt;li&gt;AWSコンソールまたは &lt;code&gt;npx ampx pipeline&lt;/code&gt; コマンドを使用して &lt;strong&gt;Amplify Hosting&lt;/strong&gt; を設定し、リポジトリに連携させます。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;CI/CD パイプラインの実行&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Git Pushをトリガーとして、Amplifyが自動的に以下の処理を行うパイプラインを開始します。

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;バックエンドデプロイ:&lt;/strong&gt; Amplify Gen 2 (CDK) 定義に基づき、&lt;strong&gt;本番用の&lt;/strong&gt; AWSリソース（DynamoDB, AppSync, Cognito）をデプロイします。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Next.js ビルド:&lt;/strong&gt; フロントエンドコードをビルドします。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ホスティング:&lt;/strong&gt; ビルドされたアプリをデプロイします。&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;ドメインと SSL の設定&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;アプリケーションにカスタムドメインを設定し、HTTPS接続（SSL証明書）を有効化します。&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;項目&lt;/th&gt;
&lt;th&gt;RDS (変更前)&lt;/th&gt;
&lt;th&gt;DynamoDB (変更後)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;データベース&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;PostgreSQL / MySQL&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;DynamoDB (NoSQL)&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;データアクセス層&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lambda (VPC内) 経由&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;AppSync (GraphQL)&lt;/strong&gt; 経由&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;VPC設定&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;必須&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;不要&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ビジネスロジック&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lambda (複雑)&lt;/td&gt;
&lt;td&gt;AppSync Resolver (シンプル) または Lambda (必要な場合のみ)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;開発の複雑性&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;高&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;低&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>aws</category>
      <category>nextjs</category>
      <category>typescript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>review of preparing dev project of aws amplify gen2 and next.js</title>
      <dc:creator>hirooka kazuya</dc:creator>
      <pubDate>Sun, 16 Nov 2025 02:29:51 +0000</pubDate>
      <link>https://forem.com/hirooka_kazuya_d7f37d3cde/review-of-preparing-dev-project-of-aws-amplify-gen2-and-nextjs-1h8i</link>
      <guid>https://forem.com/hirooka_kazuya_d7f37d3cde/review-of-preparing-dev-project-of-aws-amplify-gen2-and-nextjs-1h8i</guid>
      <description>&lt;p&gt;in these days, i prepare the developing envioromnent with aws amplify gen2 and next.js. this is the summary.&lt;/p&gt;

&lt;p&gt;install AWS CLI on [&lt;a href="https://awscli.amazonaws.com/AWSCLIV2.msi" rel="noopener noreferrer"&gt;https://awscli.amazonaws.com/AWSCLIV2.msi&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;Set up authentication credentials&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws configure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS Access Key ID: あなたのアクセスキー
AWS Secret Access Key: あなたのシークレットキ
Default region name: 例 ap-northeast-1 (東京)
Default output format: json (Enter でOK)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;confirm AWS CLI&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install node.js on &lt;a href="//Choose%20the%20Windows%20Installer%20(.msi)%20link%20toward%20the%20bottom%20of%20the%20page"&gt;https://nodejs.org/ja/download&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Move to current directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd (current directory)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Recreate npm Project / Project Setup&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Amplify Backend and Frontend SDKs in the Next.js Project Root Directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @aws-amplify/backend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @aws-amplify/data-schema
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install aws-amplify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @aws-amplify/ui-react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @aws-amplify/backend-cli --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create Directories and Files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir amplify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir amplify\data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir amplify\auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type nul &amp;gt; amplify\backend.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type nul &amp;gt; amplify\data\resource.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type nul &amp;gt; amplify\auth\resource.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the created amplify/backend.ts file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// amplify/backend.ts
import { defineBackend } from '@aws-amplify/backend';
// 認証リソースをインポート
// aws公式サイトを見ても.tsがついていないが、npx ampx sandobxのときにtsがついていないとエラーが出る
import { auth } from './auth/resource.ts'; 
import { data } from './data/resource.ts'; 

// The Amplify backend definition.
defineBackend({
  auth, // ここにインポートした 'auth' を追加
  data, // ここにインポートした 'data' を追加
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the created amplify/data/resource.ts file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// @aws-amplify/backend から必要なモジュールをインポートします。
// a: スキーマ定義のためのヘルパー (例: a.model, a.string)
// defineData: データリソース全体を定義するための関数
// type ClientSchema: フロントエンドでの型付けに使用されるユーティリティ型

import { a, defineData, type ClientSchema } from '@aws-amplify/backend';

// データのスキーマを定義します。これはGraphQLスキーマの定義に相当します。
// a.modelと定義するだけで、query(取得)、mutation(更新)も自動で定義。
const schema = a.schema({
  // 'Todo' という名前のデータモデルを定義します。
  // これは AWS DynamoDB のテーブルに対応します。
  Todo: a.model({
    // 'content' というフィールドを定義します。型は文字列 (String) です。
    content: a.string(),


    // 'isDone' というフィールドを定義します。型は真偽値 (Boolean) です。
    isDone: a.boolean()
  })
    // このモデルに対するアクセス許可（認可ルール）を定義します。
    // ここでは、パブリックな API キー (publicApiKey) を持つユーザー（クライアント）にアクセスを許可しています。
    //.authorization(allow =&amp;gt; [allow.publicApiKey()])
    .authorization(allow =&amp;gt; [
      allow.publicApiKey(), 
      // 修正後のコード: 認証済みユーザーなら誰でもOK (操作限定はできない)
      allow.authenticated() 
      // もしくは
      // allow.private()
    ])

});

// Used for code completion / highlighting when making requests from frontend
// フロントエンド (Amplify クライアント) でリクエストを行う際、
// スキーマの型補完やハイライト表示に使用するためにエクスポートされる型です。
export type Schema = ClientSchema&amp;lt;typeof schema&amp;gt;;

// defines the data resource to be deployed
// デプロイされるデータリソース（AppSync APIとDynamoDBテーブルなど）を定義し、設定します。
export const data = defineData({
  // 上で定義した GraphQL スキーマを設定します。
  schema,
  // 認証モードを設定します。
  authorizationModes: {
    // デフォルトの認証モードとして 'apiKey' を設定します。
    defaultAuthorizationMode: 'apiKey',
    // API Key 認証モードの詳細設定です。
    apiKeyAuthorizationMode: {
      // API キーの有効期限を30日に設定します。
      expiresInDays: 30
    }
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the created amplify/auth/resource.ts file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// amplify/auth/resource.ts
import { defineAuth, secret } from "@aws-amplify/backend";

/**
 * The Amplify Auth resource definition.
 */
export const auth = defineAuth({
  loginWith: {
    // ユーザー名とパスワードによるログインを有効化
    email: true,
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create Directories and Files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type nul &amp;gt; app\providers.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type nul &amp;gt; app\useAmplifyClient.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type nul &amp;gt; components\TodoList.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the app/layout.tsx file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/layout.tsx

// ★ "use client" はここに書かない（Server Componentのままにする）

import './globals.css' // グローバルCSSのインポート

// 新しく作成した Client Component ラッパーをインポート
import Providers from '../app/providers' 

//ここは、ログイン前の画面のroot

export default function RootLayout({
  children,
}: {
  children: React.ReactNode // ★ childrenを受け取る形式が必須
}) {
  return (
    &amp;lt;html lang="ja"&amp;gt;
      &amp;lt;body&amp;gt;
        {/* Providers (Client Component) でラップ */}
        &amp;lt;Providers&amp;gt;{children}&amp;lt;/Providers&amp;gt; 
      &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the app/page.tsx file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/page.tsx

'use client'
import { Authenticator } from '@aws-amplify/ui-react';
import TodoList from '../components/TodoList';// TodoListコンポーネントを切り出す

export default function DashboardPage() {
  return (
    &amp;lt;Authenticator&amp;gt;
      {({ signOut, user }) =&amp;gt; (
        &amp;lt;main&amp;gt;
          &amp;lt;h1&amp;gt;Hello, {user?.username}!&amp;lt;/h1&amp;gt;
          &amp;lt;TodoList /&amp;gt; {/* 👈 Todoリストコンポーネントを配置 */}
          &amp;lt;button onClick={signOut}&amp;gt;サインアウト&amp;lt;/button&amp;gt;
        &amp;lt;/main&amp;gt;
      )}
    &amp;lt;/Authenticator&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the app/providers.tsx file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/providers.tsx

'use client' // ★ これをファイルの先頭に記述！

import '@aws-amplify/ui-react/styles.css'
import { Amplify } from 'aws-amplify'
import outputs from '../amplify_outputs.json'


//ここで、Providersコンポーネントを定義している
//React.ReactNodeとは何だろうか、上記のimoprtのどれかに要素が入っているのだろうが

// ここで設定を一回だけ実行する
// SSR環境での二重実行を防ぐための簡易チェック

    Amplify.configure(outputs)


export default function Providers({ children }: { children: React.ReactNode }) {
  // ここでContext Providerなどを提供してもOK
  return &amp;lt;&amp;gt;{children}&amp;lt;/&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the app/useAmplifyClient.ts file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/hooks/useAmplifyClient.ts (例)
'use client'

import { useState, useEffect } from 'react';
import { generateClient, Client } from 'aws-amplify/data';
import type { Schema } from '../amplify/data/resource'; // 👈 パスに注意

// クライアントを生成し、その状態を返すカスタムフック
export function useAmplifyClient() {
  // clientの状態を管理し、初期値はnullにする
  const [client, setClient] = useState&amp;lt;Client&amp;lt;Schema&amp;gt; | null&amp;gt;(null);

  // コンポーネントがマウントされたら、クライアントを生成する
  useEffect(() =&amp;gt; {
    // Amplifyの設定が Providers.tsx で完了していることを期待
    setClient(generateClient&amp;lt;Schema&amp;gt;());
  }, []);

  return client; // client (または null) を返す
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the components/TodoList.tsx file and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/components/TodoList.tsx (または page.tsx)

'use client'

import { useState, useEffect } from "react";
// スキーマはフック内で使用されるため、ここでは不要（フックが内部でインポートしている）
// import type { Schema } from "../../amplify/data/resource"; 
// import { generateClient, Client } from "aws-amplify/data"; 

// 🚨 【重要】Todoリストの処理に必要なSchema型だけはインポートし直す
import type { Schema } from "@/amplify/data/resource"; 
import { useAmplifyClient } from '@/app/useAmplifyClient'; // 👈 カスタムフックをインポート

export default function TodoList() {
    // 🎉 クライアントの初期化ロジックをフックに任せる
    // clientにはバックエンドの全情報が入っている
    // しかし、clientは読み込み時にnull -&amp;gt;値に変わるが、
    // createのタイミングなどそれ以外では不変
    const client = useAmplifyClient();

    // todosがメモの配列、それをsetTodos関数で更新する
    // ()内は初期値で、今回は空配列[]
    // &amp;lt;&amp;gt;内はtypescriptの型定義

    // Schemaはamplify/data/resource.tsで定義したもの
    // プロパティでTodo,typeをたどっている
    // ただし、あくまでtodosのリストなので最後に[]をつけている
    // でも結局は配列のどの要素も型は同じ
    // 型にも引数にも[]をつけて単一の値と区別する
    const [todos, setTodos] = useState&amp;lt;Schema["Todo"]["type"][]&amp;gt;([]);

    // 以降、ロジックはシンプルになる

    // データ取得関数、データベースからデータを読み込む
    const fetchTodos = async () =&amp;gt; {
        if (!client) return;

        // await client.models.Todo.list()で返されるオブジェクトのイメージ
        // {
        //     data: [ // 実際のTodoの配列
        //         { id: "1", status: "牛乳を買う", isDone: false },
        //         { id: "2", status: "メールをチェック", isDone: true }
        //     ],
        //     // その他の情報（トークンなど、データ取得のメタ情報）
        //     nextToken: null 
        // }       

        // 分割代入 上記のうち、dataプロパティだけを取得する
        // だからamplify/data/resource.tsで正しく定義する必要あり

        const { data: items } = await client.models.Todo.list();

        // 以下でitemsを使った状態の更新が行われ、
        // 状態が更新されると、UIの更新が行われる(reactの基本機能)
        setTodos(items);
    };

    // 画面読み込み時クライアントがセットされた後、データをフェッチする
    // clientが読み込み後にnull -&amp;gt;値に変化することに対応している
    // useEffectはUIと関係ない処理の実行に使う
    // 二個引数を取っている
    // 一つ目は実行したい処理
    // 二つ目がトリガー
    // これは、読み込み時のclientがnull-&amp;gt;値に変わった時の動作
    // それ以降はclientはcreateの際も不変
    useEffect(() =&amp;gt; {
        if (client) {
            fetchTodos();
        }
    }, [client]); 

    // データ作成関数
    const createTodo = async () =&amp;gt; {

        if (!client) return;

        // client.models.Todo.createでデータベースにhttpリクエスト
        // window.pronpt()はブラウザの標準機能の利用
        await client.models.Todo.create({
            content: window.prompt("Todo content?"),
            isDone: false,
        });
        fetchTodos();
    }

    // クライアントが生成されるまでローディング表示をする
    if (!client) {
        return &amp;lt;div&amp;gt;データを読み込み中...&amp;lt;/div&amp;gt;;
    }

    // {...}:JSX内でJavascriptの式を埋め込み
    // key=idはUIには現れないが必須
    return (
        &amp;lt;div&amp;gt;

            &amp;lt;button onClick={createTodo}&amp;gt;Add new todo&amp;lt;/button&amp;gt;
            &amp;lt;ul&amp;gt;
                {todos.map(({ id, content }) =&amp;gt; (
                    &amp;lt;li key={id}&amp;gt;{content}&amp;lt;/li&amp;gt;
                ))}
            &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;execute the sandbox&lt;br&gt;
&lt;code&gt;npx ampx sandbox&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;when finish sandbox, Ctrl+C, and then &lt;code&gt;npx ampx sandbox delete&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  reference
&lt;/h3&gt;

&lt;p&gt;in amplify gen2 guide, sandbox can execute hot reload, the change of local code automatically link to AWS console. but it can't be realized in my developing environment. i give it up. &lt;br&gt;
alternately, by executing sandbox again, Ctrl+C and "npx ampx sandbox", the change can reflect to aws console. it can be confirmed at console of AWS AppSync Schema.&lt;/p&gt;

&lt;h3&gt;
  
  
  Production deployment
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;🖥️ AWSコンソールからのデプロイ手順（推奨）
これが、Amplify Gen 2でNext.jsアプリをGitHubと連携させ、CI/CDパイプラインを確立するための最も推奨される手順です。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;AWS Amplify コンソールに移動: AWSマネジメントコンソールにログインし、Amplify サービスを開きます。&lt;/p&gt;

&lt;p&gt;新しいアプリケーションの作成: &lt;strong&gt;「新しいアプリを作成」または「Deploy an app」&lt;/strong&gt;を選択します。&lt;/p&gt;

&lt;p&gt;ソースコードプロバイダーの選択: &lt;strong&gt;「GitHub」&lt;/strong&gt;を選択し、指示に従ってGitHubアカウントと連携します。&lt;/p&gt;

</description>
      <category>aws</category>
      <category>webdev</category>
      <category>nextjs</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
