Azure Static Web Apps now supports server-side rendering for Next.js applications🥳 #921
Replies: 29 comments 137 replies
-
Hi Reshmi, this sounds awesome. Do you have an estimate on when this feature will be available? |
Beta Was this translation helpful? Give feedback.
-
Sounds like a pretty awesome feature to add into Azure SWA, I feel like this is exactly what Azure needs to push a huge pool of developers into Azure and start getting them to use its infrastructure. Assuming this is comparable to what Vercel offers, I can see this taking off in the front-end space! One question that comes to mind is given we are rendering this content on the server, how will this impact pricing given we're not serving static files? Assuming it uses Azure Functions under the hood, would we be paying for function invocations and storage costs related to those invocations, or does it work differently? |
Beta Was this translation helpful? Give feedback.
-
Will you also support similar projects like Nuxt.js or Astro.build that have SSR ? |
Beta Was this translation helpful? Give feedback.
-
Hi @Reshmi-Sriram, |
Beta Was this translation helpful? Give feedback.
-
@Reshmi-Sriram I saw this post just now, I wonder it's all ready to go? https://techcommunity.microsoft.com/t5/apps-on-azure-blog/extending-next-js-support-in-azure-static-web-apps/ba-p/3627975 |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity I just did a simple test to see if this works and it does! At the top of the page there is "some data output" which is fetched via What an awesome low-cost solution for running SSR NextJS apps! Latency seems decent.. would be interested to get further detail on what's used under the hood and how this impacts pricing if any? cc @Reshmi-Sriram |
Beta Was this translation helpful? Give feedback.
-
A little late to the party, but Next.js SSR support is now officially in Public Preview! 🥳🥳 |
Beta Was this translation helpful? Give feedback.
-
This is great if you want to deploy a sample app. I assume this was the acceptance criteria. For any normal app though:
Also the deploy speed is laughable compared providers like netlify. 10x longer deploy times, less features, and it doesn't even work. |
Beta Was this translation helpful? Give feedback.
-
Don't know if this is related to SWA or Onyx or what but the builds timeout and we're getting errors. I wish the |
Beta Was this translation helpful? Give feedback.
-
@Reshmi-Sriram is there really a hard limit of 104857600 bytes? I mean like @AndrewVos mentioned that means you can pretty much just deploy the sample app ? |
Beta Was this translation helpful? Give feedback.
-
Is there any way to set the platform node version when building the api? I'm needing the app and the api to build with node version 16, however only the app builds with node 16. Has anyone had similar issues? I've attempted the following to resolve this without luck: see action runs |
Beta Was this translation helpful? Give feedback.
-
Hey guys, thanks for giving us this feature. Im a huge azure fan and its nice seeing suport for SSR next js apps.
|
Beta Was this translation helpful? Give feedback.
-
This is an awesome feature. We want to host our NX-wrapped React/NextJS front-end on a Static Web App. But we're getting stuck at deployment of it. If I understand it correctly: let's say there are 2 ways to deploy your NextJS app to a SWA: using I assume that means we need to build it.
We could use a Devops pipeline to deploy the That probably means we need to deploy the So that makes me think the TLDR: how do I deploy my nextjs app in an Azure Pipeline, which folder is needed? I think the way to do that, should also be added to the tutorial. |
Beta Was this translation helpful? Give feedback.
-
Is there any way to limit access to entire app only for AAD users in non-production environments? Previously, we could setup such rule in staticwebapp.config.json but it seems this configuration is not supported for hybrid Next.js case.
|
Beta Was this translation helpful? Give feedback.
-
@vivekjilla I got a new problem with deployment to a Static Web App. The Oryx builder did work great 2 days ago and I successfully deployed my app. But when I do the same thing today, there seems to be a problem installing Cypress.
How can I get Oryx to get permission to this? |
Beta Was this translation helpful? Give feedback.
-
I'm having some troubles deploying our nextjs site from an Azure DevOps pipeline. This same site deployed successfully via github actions though. I'm wondering, does the The pipeline task:- task: AzureStaticWebApp@0
displayName: Azure Deploy
inputs:
azure_static_web_apps_api_token: $(apiKey)
app_location: '/' # App source code path
api_location: '' # Api source code path - optional
output_location: '' # does not work
# output_location: '.next' # also does not work The error received:App Directory Location: '/' was found.
Looking for event info
Starting to build app with Oryx
Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx
---Oryx build logs---
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues
Oryx Version: 0.2.20221103.1, Commit: a2c65dde152b749fea395f4d1242ea9350942258, ReleaseTagName: 20221103.1
Build Operation ID: |pifaW1zNhZU=.5c46b46b_
Detecting platforms...
Could not detect any platform in the source directory.
Error: Could not detect the language from repo.
---End of Oryx build logs---
Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support.
Finished building app with Oryx
No Api directory specified. Azure Functions will not be created.
Failed to find a default file in the app artifacts folder (/). Valid default files: index.html,Index.html.
If your application contains purely static content, please verify that the variable 'app_location' in your deployment configuration file points to the root of your application.
If your application requires build steps, please validate that a default file exists in the build output directory.
For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
Exiting
##[error]Error: The process '/usr/bin/bash' failed with exit code 1
Finishing: Azure Deploy
|
Beta Was this translation helpful? Give feedback.
-
@vivekjilla would you kindly provide a summary of the discussion with @richardwem in a few bullet points and possibly a sample task? I've been following the discussion above but it feels like I'm running in circles. As of now, that's my task and build command (as per the discussions on this thread):
- deployment: 'DeployStaticwebapp'
dependsOn: ['Build']
environment: $(DevopsEnvironment)
strategy:
runOnce:
deploy:
steps:
- checkout: 'self'
- task: AzureStaticWebApp@0
inputs:
app_location: '/'
output_location: '.next'
azure_static_web_apps_api_token: $(deployment_token) For some reason, Oryx seems to understand I have API artifacts, despite the fact I've not even mentioned it on the task, and thus throws this exception: ---End of Oryx build logs---
Function Runtime Information. OS: linux, Functions Runtime: ~4, node version: 16
Finished building function app with Oryx
Zipping Api Artifacts
Done Zipping Api Artifacts
The content server has rejected the request with: BadRequest
Reason: The size of the function content was too large. The limit for this Static Web App is 104857600 bytes. Any clues on what might be happening? |
Beta Was this translation helpful? Give feedback.
-
@Reshmi-Sriram, @vivekjilla could you please provide us with any kind of roadmap of Hybrid NextJs going to general availability and supporting main missing features such as mentioned in https://learn.microsoft.com/en-us/azure/static-web-apps/nextjs#unsupported-features-in-preview? Some more transparency would help development teams a lot to plan technical decisions of their systems. |
Beta Was this translation helpful? Give feedback.
-
Hello, a few important questions:
Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi, Besides the cold starts mentioned in the thread above, there is something else that I think is a bit of a blocker for many projects. The maximum size of 100mb is not enough. The Next.js dependency alone is already 100mb (before compression). I downloaded the zip directory from a deployed Hybrid Nextjs Static Web App and I noticed that most size is taken up by the Nextjs SWC stuff. |
Beta Was this translation helpful? Give feedback.
-
Hi @vivekjilla We are trying to use On-demand revalidation which is part of Incremental Static Regeneration feature and apparently supported by Azure Static Web App as per documentation However this feature doesn't seem to be working on our case, is there any special configuration that need to be taken into account for this to happen? We have built an api under /api/publish which revalidates the page based on the parameters passed to the API, this is working fine when tested locally using next build and next start, and doesn't seem to generate any error when executed on the deployed website in Azure Static Web App, however, the page doesn't get revalidated. Any ideas? Regards, |
Beta Was this translation helpful? Give feedback.
-
Hey all, Kindly checkout the latest updates in the discussion thread here |
Beta Was this translation helpful? Give feedback.
-
Hey. I have been trying for the last couple of days to get this to build with a turborepo/next app using pnpm, but it seems impossible. Steps to repro: Current pipeline:
I've even tried to do it locally using this script in my main package.json:
With a .env.deploy:
I've both tried setting app_location to be the turborepo root and to the apps/web, but no dice. if root, then it gives me
As you can see I've even been digging down in the internals to see if I could fix it somehow with setting various settings. Problem is that I need it to recognize that its a next app, so it can figure out how to convert the .next output to functional apps. This happens in try no 2, but then it cannot install dependencies. mcr.microsoft.com/appsvc/staticappsclient is closed source so I cannot see inside and see how it functions. Full output:
|
Beta Was this translation helpful? Give feedback.
-
Is there some news about the support of new next js 13 with app directory? I was trying to deploy an app with app directory but I'm getting some routing errors. Issue Thanks. |
Beta Was this translation helpful? Give feedback.
-
Can't wait for this to become GA and be renamed to Azure Function Apps! 😎 I've always thought that Static Web Apps is a limiting brand name... |
Beta Was this translation helpful? Give feedback.
-
I'd love to use this with Azure DevOps to deploy an artifact - but the tutorial only mentions connecting a repo. Has anyone got this to work? |
Beta Was this translation helpful? Give feedback.
-
@Reshmi-Sriram, is there a publicly available roadmap that would show when hybrid web app support would reach General Availability? |
Beta Was this translation helpful? Give feedback.
-
We've rolled out improvements to our Next.js support which bring a handful of improvements, from support for Next.js 14 (& 13) along with app directory/React Server Components. I'll be closing this thread, please share your feedback and let's continue the discussion in the newest announcement: #1428 |
Beta Was this translation helpful? Give feedback.
-
UPDATE: Next.js SSR support in Static Web Apps is now officially in Public Preview! 🥳🥳
Please do give it a shot and let us know what you like and what more would you like to see!
To learn more about the feature, check out the following tech blog: https://aka.ms/swa-nextjs-ssr-blog
Azure Static Web Apps now supports Server-Side Rendering (SSR) for Next.js applications. You will now have an option to opt for either pre-rendering, server-side rendering, or incremental static regeneration during runtime for your Next.js apps. Enabling SSR would enhance the overall performance of the app.
How do I create an SSR-supported Next.js app?
Once the changes roll out, every new Static Web App created by you using the Next.js build preset will by default create an SSR-supported Next.js application.
How do I continue using my Static Next.js app?
In case you prefer to continue with your statically-exported Next.js app, follow the steps below:
IS_STATIC_EXPORT
totrue
in your YAML file as follows:For GitHub workflow -
For Azure Pipelines-
To learn more about SWA and Next.js, visit this link
Beta Was this translation helpful? Give feedback.
All reactions