# NextJS server actions and Netlify forms

**URL:** <https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381>\
**Category:** Support\
**Tags:** lambda-functions, netlify-forms, nextjs\
**Created:** [February 27, 2024, 1:25pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381 "2024-02-27T13:25:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Graemec23](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/graemec23/32/62060_2.png) [@Graemec23](https://answers.netlify.com/u/Graemec23)\
**Post date:** [February 27, 2024, 1:25pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/1 "2024-02-27T13:25:31Z")

</div>

Ive just added NextJS server actions to a project for some cookie creation, and my forms have stopped submitting. I get a LamdaTimeout error.

Is it possible to have both Netlify form, and NextJS server actions?

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [March 2, 2024, 3:15pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/2 "2024-03-02T15:15:18Z")

</div>

> [@Graemec23](#):
>
> Is it possible to have both Netlify form, and NextJS server actions?

Yes, if you make sure to make a POST request to a URL that’s not handled by your server action like `/favicon.ico` for example.

---

<div class="post-metadata">

**Author:** ![Graemec23](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/graemec23/32/62060_2.png) [@Graemec23](https://answers.netlify.com/u/Graemec23)\
**Post date:** [March 2, 2024, 3:50pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/3 "2024-03-02T15:50:15Z")

</div>

> [@Graemec23](#):
>
> LamdaTimeout

Yeah they don’t, the forms post to ‘/?no-cache=1’ and the server actions don’t post. I just use them to create a cookie like below.

```auto
`'use server';

import { cookies } from 'next/headers';

export async function createCookie(name: string, value: string, date: Date) {
  cookies().set(name, value, { secure: true, expires: date });
}`

```

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [March 2, 2024, 3:52pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/4 "2024-03-02T15:52:02Z")

</div>

> [@Graemec23](#):
>
> the forms post to ‘/?no-cache=1’

Isn’t that just your home page?

---

<div class="post-metadata">

**Author:** ![Graemec23](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/graemec23/32/62060_2.png) [@Graemec23](https://answers.netlify.com/u/Graemec23)\
**Post date:** [March 2, 2024, 4:03pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/5 "2024-03-02T16:03:46Z")

</div>

Technically yes, I was following the form guides when setting them up. Does the post url have to be a page that doesnt exist? I thought it didnt really matter as the the form name will get picked up in the request body.

> **[Forms setup](https://docs.netlify.com/forms/setup/)**
>
> Use built-in form handling to simplify adding and managing forms for your project. There’s no need to make an API call or include extra form handling code.

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [March 3, 2024, 12:59pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/6 "2024-03-03T12:59:18Z")

</div>

> [@Graemec23](#):
>
> Does the post url have to be a page that doesnt exist?

It has to be a page that exists as a _static_ page. [[Support Guide] Form problems, form debugging, 404 when submitting](https://answers.netlify.com/t/92)

---

<div class="post-metadata">

**Author:** ![Graemec23](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/graemec23/32/62060_2.png) [@Graemec23](https://answers.netlify.com/u/Graemec23)\
**Post date:** [March 3, 2024, 5:57pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/7 "2024-03-03T17:57:23Z")

</div>

Well it is a SSR rendered page via Nextjs, the forms are only a problem when I add the server actions. They work fine the rest of the time.

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [March 10, 2024, 4:51pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/8 "2024-03-10T16:51:49Z")

</div>

> [@Graemec23](#):
>
> Well it is a SSR rendered page via Nextjs

As I mentiond before, that’s vey likely the problem. Forms cannot post to a dynamic page. You can only post to a static asset to receive form submissions.

---

<div class="post-metadata">

**Author:** ![Graemec23](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/graemec23/32/62060_2.png) [@Graemec23](https://answers.netlify.com/u/Graemec23)\
**Post date:** [March 11, 2024, 2:42pm UTC](https://answers.netlify.com/t/nextjs-server-actions-and-netlify-forms/113381/9 "2024-03-11T14:42:54Z")

</div>

That seems to work thank you, I pointed the fetch request to a static html page in my public folder. The docs should be updated to specify that as its good to know.

Thanks again for the help.
